Zelda Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2023-06-06 03:20:00
Exec Total Coverage
Lines: 12703 19637 64.7%
Functions: 263 340 77.4%
Branches: 10917 21827 50.0%

Line Branch Exec Source
1 //--------------------------------------------------------
2 //--------------------------------------------------------
3 //--------------------------------------------------------
4 // Zelda Classic
5 // by Jeremy Craner, 1999-2000
6 //
7 // hero.cpp
8 //
9 // Hero's class: HeroClass
10 // Handles a lot of game play stuff as well as Hero's
11 // movement, attacking, etc.
12 //
13 //--------------------------------------------------------
14
15 #include <string.h>
16 #include <set>
17
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 #include <stdio.h>
18
19 #include "zc/hero.h"
20 #include "zc/guys.h"
21 #include "subscr.h"
22 #include "zc/zc_subscr.h"
23 #include "zc/decorations.h"
24 #include "gamedata.h"
25 #include "zc/zc_custom.h"
26 #include "zc/title.h"
27 #include "zc/ffscript.h"
28 #include "drawing.h"
29 #include "zc/combos.h"
30 #include "base/zc_math.h"
31 #include "user_object.h"
32 #include "slopes.h"
33 extern FFScript FFCore;
34 extern word combo_doscript[176];
35 extern byte itemscriptInitialised[256];
36 extern HeroClass Hero;
37 extern ZModule zcm;
38 extern zcmodule moduledata;
39 extern refInfo playerScriptData;
40 #include "zscriptversion.h"
41 #include "particles.h"
42 #include <fmt/format.h>
43 #include "zc/render.h"
44
45 extern refInfo itemScriptData[256];
46 extern refInfo itemCollectScriptData[256];
47 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
48 extern int32_t item_collect_stack[256][MAX_SCRIPT_REGISTERS];
49 extern refInfo *ri; //= NULL;
50 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
51 extern byte dmapscriptInitialised;
52 extern word item_doscript[256];
53 extern word item_collect_doscript[256];
54 extern portal mirror_portal;
55 using std::set;
56
57 extern int32_t skipcont;
58
59 extern int32_t draw_screen_clip_rect_x1;
60 extern int32_t draw_screen_clip_rect_x2;
61 extern int32_t draw_screen_clip_rect_y1;
62 extern int32_t draw_screen_clip_rect_y2;
63 extern word global_wait;
64 extern bool player_waitdraw;
65 extern bool dmap_waitdraw;
66 extern bool passive_subscreen_waitdraw;
67 extern bool active_subscreen_waitdraw;
68
69 int32_t hero_count = -1;
70 int32_t hero_animation_speed = 1; //lower is faster animation
71 static int32_t z3step = 2;
72 34 static zfix hero_newstep(1.5);
73 34 static zfix hero_newstep_diag(1.5);
74 bool did_scripta=false;
75 bool did_scriptb=false;
76 bool did_scriptl=false;
77 byte lshift = 0;
78 int32_t dowpn = -1;
79 int32_t directItem = -1; //Is set if Hero is currently using an item directly
80 int32_t directItemA = -1;
81 int32_t directItemB = -1;
82 int32_t directItemX = -1;
83 int32_t directItemY = -1;
84 int32_t directWpn = -1;
85 int32_t whistleitem=-1;
86 extern word g_doscript;
87 extern word player_doscript;
88 extern word dmap_doscript;
89 extern word passive_subscreen_doscript;
90 extern int32_t script_hero_cset;
91
92 void playLevelMusic();
93
94 extern particle_list particles;
95
96 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
97
98 #define CANFORCEFACEUP (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
99 #define NO_GRIDLOCK (get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK)||get_bit(quest_rules, qr_NEW_HERO_MOVEMENT2))
100 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
101 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_bit(quest_rules,qr_BROKEN_Z3_ANIMATION))
102
103 1833 bool item_error()
104 {
105
2/2
✓ Branch 0 taken 1809 times.
✓ Branch 1 taken 24 times.
1833 if(QMisc.miscsfx[sfxERROR])
106 1809 sfx(QMisc.miscsfx[sfxERROR]);
107 1833 return false;
108 }
109 17550695 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
110 {
111
2/2
✓ Branch 0 taken 19493 times.
✓ Branch 1 taken 17531202 times.
17550695 if(check_new_slope(x, y+1, 16, 16, oldx, oldy) < 0) return true;
112 17531202 return false;
113 17550695 }
114
115 5860009 static inline bool platform_fallthrough(bool doslopecheck = true)
116 {
117
5/6
✓ Branch 0 taken 5860009 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5848183 times.
✓ Branch 3 taken 11826 times.
✓ Branch 4 taken 5842467 times.
✓ Branch 5 taken 5716 times.
16102843 return (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
118
2/2
✓ Branch 0 taken 742545 times.
✓ Branch 1 taken 730719 times.
5860009 || (getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
119
6/6
✓ Branch 0 taken 4384785 times.
✓ Branch 1 taken 5127330 times.
✓ Branch 2 taken 339572 times.
✓ Branch 3 taken 5518477 times.
✓ Branch 4 taken 312189 times.
✓ Branch 5 taken 27383 times.
1473264 || (Hero.jumping < 0 && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS));
120 }
121
122 static inline bool on_sideview_solid(int32_t x, int32_t y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
123 {
124 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16, (slopesmisc == 3)) < 0) return true;
125 if(slopesmisc == 2) return false;
126 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
127 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
128 if (platform_fallthrough() && !ignoreFallthrough) return false;
129 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16) < 0) return true;
130 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
131 return true;
132 return false;
133 }
134
135 8542557 static inline bool on_sideview_solid_oldpos(int32_t x, int32_t y, int32_t oldx, int32_t oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
136 {
137
4/4
✓ Branch 0 taken 1861454 times.
✓ Branch 1 taken 6681103 times.
✓ Branch 2 taken 1800745 times.
✓ Branch 3 taken 60709 times.
8542557 if(slopesmisc != 1 && check_new_slope(x, y+1, 16, 16, oldx, oldy, (slopesmisc == 3)) < 0) return true;
138
2/2
✓ Branch 0 taken 127631 times.
✓ Branch 1 taken 8354217 times.
8481848 if(slopesmisc == 2) return false;
139
4/4
✓ Branch 0 taken 6032537 times.
✓ Branch 1 taken 2321680 times.
✓ Branch 2 taken 171854 times.
✓ Branch 3 taken 5860683 times.
8354217 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
140
6/6
✓ Branch 0 taken 52031 times.
✓ Branch 1 taken 5808652 times.
✓ Branch 2 taken 2120 times.
✓ Branch 3 taken 49911 times.
✓ Branch 4 taken 1445 times.
✓ Branch 5 taken 675 times.
5860683 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
141
4/4
✓ Branch 0 taken 2011 times.
✓ Branch 1 taken 5857997 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 1713 times.
5860008 if (platform_fallthrough() && !ignoreFallthrough) return false;
142
4/4
✓ Branch 0 taken 767055 times.
✓ Branch 1 taken 5091240 times.
✓ Branch 2 taken 764284 times.
✓ Branch 3 taken 2771 times.
5858295 if (slopesmisc != 1 && check_new_slope(x, y + 1, 16, 16, oldx, oldy) < 0) return true;
143
6/6
✓ Branch 0 taken 1702497 times.
✓ Branch 1 taken 4153027 times.
✓ Branch 2 taken 1679515 times.
✓ Branch 3 taken 22982 times.
✓ Branch 4 taken 262 times.
✓ Branch 5 taken 1679253 times.
5855524 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
144 23244 return true;
145 5832280 return false;
146 8542557 }
147
148
149 18545695 bool usingActiveShield(int32_t itmid)
150 {
151
2/2
✓ Branch 0 taken 2579304 times.
✓ Branch 1 taken 15966391 times.
18545695 switch(Hero.action) //filter allowed actions
152 {
153 case none: case walking: case rafting:
154 case gothit: case swimhit:
155 15966391 break;
156 2579304 default: return false;
157 }
158
3/4
✓ Branch 0 taken 942 times.
✓ Branch 1 taken 15965449 times.
✓ Branch 2 taken 942 times.
✗ Branch 3 not taken.
15966391 if(Hero.lift_wpn && (Hero.liftflags&LIFTFL_DIS_SHIELD)) return false;
159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15966391 times.
15966391 if(itmid < 0)
160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15966391 times.
15966391 itmid = (Hero.active_shield_id < 0
161 15966391 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
162
2/2
✓ Branch 0 taken 14489058 times.
✓ Branch 1 taken 1477333 times.
15966391 if(itmid < 0) return false;
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14489058 times.
14489058 if(item_disabled(itmid)) return false;
164
1/2
✓ Branch 0 taken 14489058 times.
✗ Branch 1 not taken.
14489058 if(!checkitem_jinx(itmid)) return false;
165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14489058 times.
14489058 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
166 if(!isItmPressed(itmid)) return false;
167 return (checkbunny(itmid) && checkmagiccost(itmid));
168 18545695 }
169 11501058 int32_t getCurrentShield(bool requireActive)
170 {
171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11501058 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11501058 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
172 return Hero.active_shield_id;
173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11501058 times.
11501058 if(!requireActive) return current_item_id(itype_shield);
174 return -1;
175 11501058 }
176 91874 int32_t getCurrentActiveShield()
177 {
178 91874 int32_t id = Hero.active_shield_id;
179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 91874 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
91874 if(id > -1 && usingActiveShield(id))
180 return id;
181 91874 return -1;
182 91874 }
183 6418211 int32_t refreshActiveShield()
184 {
185 6418211 int32_t id = -1;
186
2/2
✓ Branch 0 taken 6239769 times.
✓ Branch 1 taken 178442 times.
6418211 if(DrunkcBbtn())
187 {
188 178442 itemdata const& dat = itemsbuf[Bwpn&0xFFF];
189
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 178442 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
178442 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
190 {
191 id = Bwpn&0xFFF;
192 }
193 178442 }
194
3/4
✓ Branch 0 taken 6418211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5862760 times.
✓ Branch 3 taken 555451 times.
6418211 if(id < 0 && DrunkcAbtn())
195 {
196 555451 itemdata const& dat = itemsbuf[Awpn&0xFFF];
197
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 555451 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
555451 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
198 {
199 id = Awpn&0xFFF;
200 }
201 555451 }
202
3/4
✓ Branch 0 taken 6418211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6418139 times.
✓ Branch 3 taken 72 times.
6418211 if(id < 0 && DrunkcEx1btn())
203 {
204 72 itemdata const& dat = itemsbuf[Xwpn&0xFFF];
205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
206 {
207 id = Xwpn&0xFFF;
208 }
209 72 }
210
3/4
✓ Branch 0 taken 6418211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6417054 times.
✓ Branch 3 taken 1157 times.
6418211 if(id < 0 && DrunkcEx2btn())
211 {
212 1157 itemdata const& dat = itemsbuf[Ywpn&0xFFF];
213
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1157 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1157 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
214 {
215 id = Ywpn&0xFFF;
216 }
217 1157 }
218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6418211 times.
6418211 if(!usingActiveShield(id))
219 6418211 return -1;
220 return id;
221 6418211 }
222 static bool is_immobile()
223 {
224 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
225 return false;
226 zfix rate(Hero.steprate);
227 int32_t shieldid = getCurrentActiveShield();
228 if(shieldid > -1)
229 {
230 itemdata const& shield = itemsbuf[shieldid];
231 if(shield.flags & ITEM_FLAG10) //Change Speed flag
232 {
233 zfix perc = shield.misc7;
234 perc /= 100;
235 if(perc < 0)
236 perc = (perc*-1)+1;
237 rate = (rate * perc) + shield.misc8;
238 }
239 }
240 return rate != 0;
241 }
242
243 12893153 bool nomove_action(int action)
244 {
245
2/2
✓ Branch 0 taken 12447157 times.
✓ Branch 1 taken 445996 times.
12893153 switch(action)
246 {
247 case gothit:
248 case drowning:
249 case lavadrowning:
250 case sidedrowning:
251 case falling:
252 case freeze:
253 case sideswimfreeze:
254 case scrolling:
255 case casting:
256 case sideswimcasting:
257 case landhold1:
258 case landhold2:
259 case waterhold1:
260 case waterhold2:
261 case sidewaterhold1:
262 case sidewaterhold2:
263 case hopping:
264 case inwind:
265 445996 return true;
266 }
267 12447157 return false;
268 12893153 }
269
270 6609371 bool HeroClass::isStanding(bool forJump)
271 {
272
3/4
✓ Branch 0 taken 6605205 times.
✓ Branch 1 taken 4166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6605205 times.
6609371 if(z || fakez) return false;
273
4/4
✓ Branch 0 taken 274226 times.
✓ Branch 1 taken 6330979 times.
✓ Branch 2 taken 640 times.
✓ Branch 3 taken 130319 times.
6736164 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)
274
4/6
✓ Branch 0 taken 130959 times.
✓ Branch 1 taken 143267 times.
✓ Branch 2 taken 130959 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 130959 times.
✗ Branch 5 not taken.
274226 && !ladderx && !laddery && !getOnSideviewLadder())
275 130319 return false;
276
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6474850 times.
6474886 if(hoverclk) return false;
277
2/2
✓ Branch 0 taken 221234 times.
✓ Branch 1 taken 6253616 times.
6474850 if(nomove_action(action)) return false;
278 6253616 int32_t val = check_pitslide();
279
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6253605 times.
6253616 if(val == -2) return false;
280
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 6253590 times.
6253605 if(val == -1) return true;
281 15 return forJump;
282 6609371 }
283 29659 bool HeroClass::isLifting()
284 {
285
2/2
✓ Branch 0 taken 502 times.
✓ Branch 1 taken 29157 times.
29659 if(lift_wpn) return true;
286 29157 return false;
287 29659 }
288 11 void HeroClass::set_liftflags(int liftid)
289 {
290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(unsigned(liftid) >= MAXITEMS)
291 return;
292 11 itemdata const& itm = itemsbuf[liftid];
293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 SETFLAG(liftflags, LIFTFL_DIS_SHIELD, itm.flags & ITEM_FLAG3);
294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 SETFLAG(liftflags, LIFTFL_DIS_ITEMS, itm.flags & ITEM_FLAG4);
295 11 }
296
297 46869 void HeroClass::set_respawn_point(bool setwarp)
298 {
299
2/2
✓ Branch 0 taken 38854 times.
✓ Branch 1 taken 8015 times.
46869 if(setwarp)
300 {
301 8015 warpx = x;
302 8015 warpy = y;
303 8015 raftwarpx = x;
304 8015 raftwarpy = y;
305 8015 }
306
2/2
✓ Branch 0 taken 18702 times.
✓ Branch 1 taken 28167 times.
46869 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
307 {
308
2/2
✓ Branch 0 taken 26865 times.
✓ Branch 1 taken 1302 times.
28167 switch(action)
309 {
310 case none: case walking:
311 26865 break;
312 default:
313 1302 return; //Not a 'safe action'
314 }
315
5/6
✓ Branch 0 taken 26501 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 26501 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 26482 times.
26865 if(z > 0 || fakez > 0 || hoverclk) return; //in air
316
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26481 times.
26482 if(check_pitslide(true) != -1) return; //On a pit
317
318 { //Check water
319 26481 int32_t water = 0;
320 26481 int32_t types[4] = {0};
321 26481 int32_t x1 = x+4, x2 = x+11,
322 26481 y1 = y+9, y2 = y+15;
323
1/2
✓ Branch 0 taken 26481 times.
✗ Branch 1 not taken.
26481 if (get_bit(quest_rules, qr_SMARTER_WATER))
324 {
325
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 26456 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
26482 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
326
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
327
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
328 1 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
329 26481 }
330 else
331 {
332 types[0] = COMBOTYPE(x1,y1);
333
334 if(MAPFFCOMBO(x1,y1))
335 types[0] = FFCOMBOTYPE(x1,y1);
336
337 types[1] = COMBOTYPE(x1,y2);
338
339 if(MAPFFCOMBO(x1,y2))
340 types[1] = FFCOMBOTYPE(x1,y2);
341
342 types[2] = COMBOTYPE(x2,y1);
343
344 if(MAPFFCOMBO(x2,y1))
345 types[2] = FFCOMBOTYPE(x2,y1);
346
347 types[3] = COMBOTYPE(x2,y2);
348
349 if(MAPFFCOMBO(x2,y2))
350 types[3] = FFCOMBOTYPE(x2,y2);
351
352 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
353 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
354 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
355
356 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
357 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
358 water = typec;
359 }
360
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26480 times.
26481 if(water > 0)
361 {
362 1 return;
363 }
364 } //End check water
365
366 132400 int poses[4] = {
367 26480 COMBOPOS(x,y+(bigHitbox?0:8)),
368 26480 COMBOPOS(x,y+15),
369 26480 COMBOPOS(x+15,y+(bigHitbox?0:8)),
370 26480 COMBOPOS(x+15,y+15)
371 };
372
2/2
✓ Branch 0 taken 105013 times.
✓ Branch 1 taken 26151 times.
131164 for(auto pos : poses)
373 {
374
2/2
✓ Branch 0 taken 104684 times.
✓ Branch 1 taken 329 times.
105013 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
375 329 return;
376 }
377 26151 }
378 44853 respawn_x = x;
379 44853 respawn_y = y;
380 44853 respawn_scr = currscr;
381 44853 respawn_dmap = currdmap;
382 46869 }
383
384 13 void HeroClass::go_respawn_point()
385 {
386 13 x = respawn_x;
387 13 y = respawn_y;
388 13 handle_portal_prox(&mirror_portal);
389
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 portals.forEach([&](sprite& p)
390 {
391 handle_portal_prox((portal*)&p);
392 return false;
393 });
394 13 warpx=x;
395 13 warpy=y;
396 13 raftwarpx = x;
397 13 raftwarpy = y;
398 13 trySideviewLadder(); //Cling to ladder automatically
399
400
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if(get_bit(quest_rules, qr_OLD_RESPAWN_POINTS))
401 12 return; //No cross-screen return
402
403
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(currdmap != respawn_dmap || currscr != respawn_scr)
404 {
405 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr,
406 -1, -1, 0, 0, warpFlagNOSTEPFORWARD|warpFlagDONTKILLMUSIC, -1);
407 }
408 13 }
409
410 12232 void HeroClass::trySideviewLadder()
411 {
412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12232 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12232 if(canSideviewLadder() && !on_sideview_solid_oldpos(x,y,old_x,old_y))
413 setOnSideviewLadder(true);
414 12232 }
415
416 29371158 bool HeroClass::can_pitfall(bool ignore_hover)
417 {
418
27/30
✓ Branch 0 taken 28733608 times.
✓ Branch 1 taken 637550 times.
✓ Branch 2 taken 28541041 times.
✓ Branch 3 taken 192567 times.
✓ Branch 4 taken 28533747 times.
✓ Branch 5 taken 7294 times.
✓ Branch 6 taken 28533747 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28533693 times.
✓ Branch 9 taken 54 times.
✓ Branch 10 taken 28533693 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 70 times.
✓ Branch 13 taken 28533623 times.
✓ Branch 14 taken 28524346 times.
✓ Branch 15 taken 9347 times.
✓ Branch 16 taken 28523479 times.
✓ Branch 17 taken 867 times.
✓ Branch 18 taken 28522233 times.
✓ Branch 19 taken 1246 times.
✓ Branch 20 taken 28441993 times.
✓ Branch 21 taken 80240 times.
✓ Branch 22 taken 28005584 times.
✓ Branch 23 taken 436409 times.
✓ Branch 24 taken 28005304 times.
✓ Branch 25 taken 280 times.
✓ Branch 26 taken 28005304 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1280 times.
✓ Branch 29 taken 28004024 times.
29371158 return (!(isSideViewGravity()||action==rafting||z>0||fakez>0||fall<0||fakefall<0||(hoverclk && !ignore_hover)||inlikelike||inwallm||pull_hero||toogam||(ladderx||laddery)||getOnSideviewLadder()||drownclk||!(moveflags & FLAG_CAN_PITFALL)));
419 }
420
421 3705606 int32_t HeroClass::DrunkClock()
422 {
423 3705606 return drunkclk;
424 }
425 void HeroClass::setDrunkClock(int32_t newdrunkclk)
426 {
427 drunkclk=newdrunkclk;
428 }
429
430 int32_t HeroClass::StunClock()
431 {
432 return lstunclock;
433 }
434 void HeroClass::setStunClock(int32_t v)
435 {
436 lstunclock=v;
437 }
438
439 98523235 int32_t HeroClass::BunnyClock()
440 {
441 98523235 return lbunnyclock;
442 }
443 void HeroClass::setBunnyClock(int32_t v)
444 {
445 lbunnyclock=v;
446 }
447
448
11/22
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 34 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 34 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 34 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 34 times.
✗ Branch 21 not taken.
102 HeroClass::HeroClass() : sprite()
449 68 {
450 34 lift_wpn = nullptr;
451
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 init();
452 34 }
453
454 //2.6
455
456 //Stop the subscreen from falling. -Z
457
458 716 bool HeroClass::stopSubscreenFalling(){
459 716 return preventsubscreenfalling;
460 }
461
462 void HeroClass::stopSubscreenFalling(bool v){
463 preventsubscreenfalling = v;
464 }
465
466
467 //Set the button items by brute force
468
469 void HeroClass::setAButtonItem(int32_t itmslot){
470 game->awpn = itmslot;
471 }
472
473 void HeroClass::setBButtonItem(int32_t itmslot){
474 game->bwpn = itmslot;
475 }
476
477 6418559 void HeroClass::ClearhitHeroUIDs()
478 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
479 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
480 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
481 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
482 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
483 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
484 //clear it on the next frame, but that had the SAME outcome.
485 //Where and how can I clear a value at the end of every frame, so that:
486 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
487 // 2. FFCs can read it before Waitframe. --same.
488 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
489
2/2
✓ Branch 0 taken 109115503 times.
✓ Branch 1 taken 6418559 times.
115534062 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ )
490 {
491 /*
492 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
493 {
494 //Z_scripterrlog("frame is: %d\n", frame);
495 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
496 lastHitBy[q][0] = 0;
497 }
498 */
499 109115503 lastHitBy[q][0] = 0;
500 109115503 }
501 6418559 }
502
503 34306 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
504 {
505 34306 lastHitBy[type][0] = screen_index;
506 34306 }
507
508 2929 int32_t HeroClass::gethitHeroUID(int32_t type)
509 {
510 2929 return lastHitBy[type][0];
511 }
512
513 void HeroClass::set_defence(int32_t type, int32_t v)
514 {
515 defence[type] = v;
516 }
517
518 int32_t HeroClass::get_defence(int32_t type)
519 {
520 return defence[type];
521 }
522
523
524 //Set Hero;s hurt sfx
525 void HeroClass::setHurtSFX(int32_t sfx)
526 {
527 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
528 }
529 6882 int32_t HeroClass::getHurtSFX()
530 {
531 6882 return QMisc.miscsfx[sfxHURTPLAYER];
532 }
533
534 bool HeroClass::getDiagMove()
535 {
536 return diagonalMovement;
537 }
538 void HeroClass::setDiagMove(bool newdiag)
539 {
540 diagonalMovement=newdiag;
541 }
542 9024 bool HeroClass::getBigHitbox()
543 {
544 9024 return bigHitbox;
545 }
546 335 void HeroClass::setBigHitbox(bool newbigHitbox)
547 {
548 335 bigHitbox=newbigHitbox;
549 335 syofs = bigHitbox?0:8;
550 335 sysz_ofs = bigHitbox?0:-8;
551 335 }
552 5424 int32_t HeroClass::getStepRate()
553 {
554 5424 return steprate;
555 }
556 void HeroClass::setStepRate(int32_t newrate)
557 {
558 steprate = newrate;
559 }
560 int32_t HeroClass::getSwimUpRate()
561 {
562 return game->get_sideswim_up();
563 }
564 void HeroClass::setSwimUpRate(int32_t newrate)
565 {
566 game->set_sideswim_up(newrate);
567 }
568 int32_t HeroClass::getSwimSideRate()
569 {
570 return game->get_sideswim_side();
571 }
572 void HeroClass::setSwimSideRate(int32_t newrate)
573 {
574 game->set_sideswim_side(newrate);
575 }
576 int32_t HeroClass::getSwimDownRate()
577 {
578 return game->get_sideswim_down();
579 }
580 void HeroClass::setSwimDownRate(int32_t newrate)
581 {
582 game->set_sideswim_down(newrate);
583 }
584
585
586 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
587 4632996 void HeroClass::herostep()
588 {
589
2/2
✓ Branch 0 taken 4243818 times.
✓ Branch 1 taken 389178 times.
4632996 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
590 //need to run all global/hero/dmap scripts here?
591 4632996 }
592
593 74723 bool is_moving()
594 {
595
6/6
✓ Branch 0 taken 60449 times.
✓ Branch 1 taken 14274 times.
✓ Branch 2 taken 45245 times.
✓ Branch 3 taken 15204 times.
✓ Branch 4 taken 18958 times.
✓ Branch 5 taken 26287 times.
74723 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
596 }
597
598 // called by ALLOFF()
599 13594 void HeroClass::resetflags(bool all)
600 {
601 13594 refilling=REFILL_NONE;
602 13594 inwallm=false;
603 13594 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
604 13594 usecounts.clear();
605
606
4/4
✓ Branch 0 taken 13549 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 13447 times.
13594 if(swordclk>0 || all)
607 {
608 147 swordclk=0;
609 147 verifyAWpn();
610 147 }
611
4/4
✓ Branch 0 taken 13586 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 13484 times.
13594 if(itemclk>0 || all)
612 110 itemclk=0;
613
614
2/2
✓ Branch 0 taken 13492 times.
✓ Branch 1 taken 102 times.
13594 if(all)
615 {
616 102 DivineProtectionShieldClk=0;
617
618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(div_prot_item != -1)
619 {
620 stop_sfx(itemsbuf[div_prot_item].usesound);
621 stop_sfx(itemsbuf[div_prot_item].usesound+1);
622 }
623
624 102 div_prot_item = -1;
625 102 hoverclk=jumping=0;
626 102 hoverflags = 0;
627 102 }
628 13594 damageovertimeclk = 0;
629 13594 newconveyorclk = 0;
630 13594 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
631
2/2
✓ Branch 0 taken 13594 times.
✓ Branch 1 taken 95158 times.
108752 for(auto q = 0; q < 7; ++q)
632 95158 hooked_undercombos[q] = -1;
633 13594 hopclk=0;
634 13594 hopdir=-1;
635 13594 attackclk=0;
636 13594 stomping=false;
637 13594 reset_swordcharge();
638 13594 diveclk=drownclk=drownCombo=0;
639 13594 action=none; FFCore.setHeroAction(none);
640 13594 conveyor_flags=0;
641 13594 magiccastclk=0;
642 13594 magicitem=-1;
643 13594 }
644
645 //Can use this for Hero->Stun. -Z
646 7856 void HeroClass::Freeze()
647 {
648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7856 times.
7856 if (action != inwind)
649 {
650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7856 times.
7856 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
651 7856 else {action=freeze; FFCore.setHeroAction(freeze);}
652 // also cancel Hero's attack
653 7856 attackclk = 0;
654 7856 }
655 7856 }
656 1465 void HeroClass::unfreeze()
657 {
658
3/4
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 859 times.
✓ Branch 2 taken 606 times.
✗ Branch 3 not taken.
1465 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
659
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1465 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1465 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
660 1465 }
661
662 10 void HeroClass::Drown(int32_t state)
663 {
664 // Hero should never drown if the ladder is out
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(ladderx+laddery)
666 return;
667
668 10 drop_liftwpn();
669
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 switch(state)
670 {
671 case 1:
672 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
673 attackclk=0;
674 attack=wNone;
675 attackid=-1;
676 reset_swordcharge();
677 drownclk=64;
678 z=fakez=fall=fakefall=0;
679 break;
680
681
682 default:
683 {
684
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
685 10 else {action=drowning; FFCore.setHeroAction(drowning);}
686 10 attackclk=0;
687 10 attack=wNone;
688 10 attackid=-1;
689 10 reset_swordcharge();
690 10 drownclk=64;
691 10 z=fakez=fall=fakefall=0;
692 10 break;
693 }
694 }
695
696 10 }
697
698 1138 void HeroClass::finishedmsg()
699 {
700 //these are to cancel out any keys that Hero may
701 //be pressing so he doesn't attack at the end of
702 //a message if he was scrolling through it quickly.
703 1138 rAbtn();
704 1138 rBbtn();
705 1138 unfreeze();
706
707
3/4
✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1122 times.
2260 if(action == landhold1 ||
708
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == landhold2 ||
709
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == waterhold1 ||
710
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == waterhold2 ||
711
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 action == sidewaterhold1 ||
712 1122 action == sidewaterhold2)
713 {
714 16 holdclk = 1;
715 16 }
716 1138 }
717 35 void HeroClass::setEaten(int32_t i)
718 {
719 35 inlikelike=i;
720 35 }
721 32 int32_t HeroClass::getEaten()
722 {
723 32 return inlikelike;
724 }
725 13736337 zfix HeroClass::getX()
726 {
727 13736337 return x;
728 }
729 13153105 zfix HeroClass::getY()
730 {
731 13153105 return y;
732 }
733 41204610 zfix HeroClass::getZ()
734 {
735 41204610 return z;
736 }
737 27087269 zfix HeroClass::getFakeZ()
738 {
739 27087269 return fakez;
740 }
741 433888 zfix HeroClass::getFall()
742 {
743 433888 return fall;
744 }
745 zfix HeroClass::getFakeFall()
746 {
747 return fakefall;
748 }
749 zfix HeroClass::getXOfs()
750 {
751 return xofs;
752 }
753 zfix HeroClass::getYOfs()
754 {
755 return yofs;
756 }
757 void HeroClass::setXOfs(int32_t newxofs)
758 {
759 xofs=newxofs;
760 }
761 void HeroClass::setYOfs(int32_t newyofs)
762 {
763 yofs=newyofs;
764 }
765 int32_t HeroClass::getHXOfs()
766 {
767 return hxofs;
768 }
769 int32_t HeroClass::getHYOfs()
770 {
771 return hyofs;
772 }
773 int32_t HeroClass::getHXSz()
774 {
775 return hxsz;
776 }
777 int32_t HeroClass::getHYSz()
778 {
779 return hysz;
780 }
781 35776 zfix HeroClass::getClimbCoverX()
782 {
783 35776 return climb_cover_x;
784 }
785 35776 zfix HeroClass::getClimbCoverY()
786 {
787 35776 return climb_cover_y;
788 }
789 int32_t HeroClass::getLadderX()
790 {
791 return ladderx;
792 }
793 int32_t HeroClass::getLadderY()
794 {
795 return laddery;
796 }
797
798 437391 void HeroClass::setX(int32_t new_x)
799 {
800 437391 zfix dx=new_x-x;
801 437391 justmoved = 2;
802
1/2
✓ Branch 0 taken 437391 times.
✗ Branch 1 not taken.
437391 if(Lwpns.idFirst(wHookshot)>-1)
803 {
804 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
805 hs_startx+=(int32_t)dx;
806 }
807
808
1/2
✓ Branch 0 taken 437391 times.
✗ Branch 1 not taken.
437391 if(Lwpns.idFirst(wHSHandle)>-1)
809 {
810 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
811 }
812
813
1/2
✓ Branch 0 taken 437391 times.
✗ Branch 1 not taken.
437391 if(chainlinks.Count()>0)
814 {
815 for(int32_t j=0; j<chainlinks.Count(); j++)
816 {
817 chainlinks.spr(j)->x+=dx;
818 }
819 }
820
821 437391 x=new_x;
822
823 // A kludge
824
4/4
✓ Branch 0 taken 2543 times.
✓ Branch 1 taken 434848 times.
✓ Branch 2 taken 1591 times.
✓ Branch 3 taken 952 times.
437391 if(!diagonalMovement && dir<=down)
825 952 is_on_conveyor=true;
826 437391 }
827
828 453023 void HeroClass::setY(int32_t new_y)
829 {
830 453023 zfix dy=new_y-y;
831 453023 justmoved = 2;
832
1/2
✓ Branch 0 taken 453023 times.
✗ Branch 1 not taken.
453023 if(Lwpns.idFirst(wHookshot)>-1)
833 {
834 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
835 hs_starty+=(int32_t)dy;
836 }
837
838
1/2
✓ Branch 0 taken 453023 times.
✗ Branch 1 not taken.
453023 if(Lwpns.idFirst(wHSHandle)>-1)
839 {
840 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
841 }
842
843
1/2
✓ Branch 0 taken 453023 times.
✗ Branch 1 not taken.
453023 if(chainlinks.Count()>0)
844 {
845 for(int32_t j=0; j<chainlinks.Count(); j++)
846 {
847 chainlinks.spr(j)->y+=dy;
848 }
849 }
850
851 453023 y=new_y;
852
853 // A kludge
854
4/4
✓ Branch 0 taken 2543 times.
✓ Branch 1 taken 450480 times.
✓ Branch 2 taken 952 times.
✓ Branch 3 taken 1591 times.
453023 if(!diagonalMovement && dir>=left)
855 1591 is_on_conveyor=true;
856 453023 }
857
858 2 void HeroClass::setZ(int32_t new_z)
859 {
860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(isSideViewHero())
861 return;
862
863
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(z==0 && new_z > 0)
864 {
865
1/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 switch(action)
866 {
867 case swimming:
868 {
869 diveclk=0;
870 action=walking; FFCore.setHeroAction(walking);
871 break;
872 }
873
874 case waterhold1:
875 {
876 action=landhold1; FFCore.setHeroAction(landhold1);
877 break;
878 }
879
880 case waterhold2:
881 {
882 action=landhold2; FFCore.setHeroAction(landhold2);
883 break;
884 }
885
886 default:
887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(charging) //!DIMITODO: Let Hero jump while charging sword
888 {
889 reset_swordcharge();
890 attackclk=0;
891 }
892
893 2 break;
894 }
895 2 }
896
897
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 z=(new_z>0 ? new_z : 0);
898 2 }
899
900 void HeroClass::setFakeZ(int32_t new_z)
901 {
902 if(isSideViewHero())
903 return;
904
905 if(fakez==0 && new_z > 0)
906 {
907 switch(action)
908 {
909 case swimming:
910 {
911 diveclk=0;
912 action=walking; FFCore.setHeroAction(walking);
913 break;
914 }
915
916 case waterhold1:
917 {
918 action=landhold1; FFCore.setHeroAction(landhold1);
919 break;
920 }
921
922 case waterhold2:
923 {
924 action=landhold2; FFCore.setHeroAction(landhold2);
925 break;
926 }
927
928 default:
929 if(charging) //!DIMITODO: Let Hero jump while charging sword
930 {
931 reset_swordcharge();
932 attackclk=0;
933 }
934
935 break;
936 }
937 }
938
939 fakez=(new_z>0 ? new_z : 0);
940 }
941
942 1211 void HeroClass::setXfix(zfix new_x)
943 {
944 //Z_scripterrlog("setxdbl: %f\n",new_x);
945 1211 zfix dx=new_x-x;
946 1211 justmoved = 2;
947
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHookshot)>-1)
948 {
949 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
950 hs_startx+=(int32_t)dx;
951 }
952
953
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHSHandle)>-1)
954 {
955 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
956 }
957
958
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(chainlinks.Count()>0)
959 {
960 for(int32_t j=0; j<chainlinks.Count(); j++)
961 {
962 chainlinks.spr(j)->x+=dx;
963 }
964 }
965
966 1211 x=new_x;
967
968 // A kludge
969
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1211 if(!diagonalMovement && dir<=down)
970 is_on_conveyor=true;
971 1211 }
972
973 1081 void HeroClass::setYfix(zfix new_y)
974 {
975 1081 zfix dy=new_y-y;
976 1081 justmoved = 2;
977
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHookshot)>-1)
978 {
979 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
980 hs_starty+=(int32_t)dy;
981 }
982
983
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHSHandle)>-1)
984 {
985 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
986 }
987
988
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(chainlinks.Count()>0)
989 {
990 for(int32_t j=0; j<chainlinks.Count(); j++)
991 {
992 chainlinks.spr(j)->y+=dy;
993 }
994 }
995
996 1081 y=new_y;
997
998 // A kludge
999
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1081 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1081 if(!diagonalMovement && dir>=left)
1000 is_on_conveyor=true;
1001 1081 }
1002
1003 2767 void HeroClass::setZfix(zfix new_z)
1004 {
1005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767 times.
2767 if(isSideViewHero())
1006 return;
1007
1008
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2754 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 7 times.
2767 if(z==0 && new_z > 0)
1009 {
1010
1/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 switch(action)
1011 {
1012 case swimming:
1013 {
1014 diveclk=0;
1015 action=walking; FFCore.setHeroAction(walking);
1016 break;
1017 }
1018
1019 case waterhold1:
1020 {
1021 action=landhold1; FFCore.setHeroAction(landhold1);
1022 break;
1023 }
1024
1025 case waterhold2:
1026 {
1027 action=landhold2; FFCore.setHeroAction(landhold2);
1028 break;
1029 }
1030
1031 default:
1032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(charging) //!DIMITODO: Let Hero jump while charging sword
1033 {
1034 reset_swordcharge();
1035 attackclk=0;
1036 }
1037
1038 7 break;
1039 }
1040 7 }
1041
1042
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 6 times.
2767 z=(new_z>0 ? new_z : zfix(0));
1043 2767 }
1044
1045 void HeroClass::setFakeZfix(zfix new_z)
1046 {
1047 if(isSideViewHero())
1048 return;
1049
1050 if(fakez==0 && new_z > 0)
1051 {
1052 switch(action)
1053 {
1054 case swimming:
1055 {
1056 diveclk=0;
1057 action=walking; FFCore.setHeroAction(walking);
1058 break;
1059 }
1060
1061 case waterhold1:
1062 {
1063 action=landhold1; FFCore.setHeroAction(landhold1);
1064 break;
1065 }
1066
1067 case waterhold2:
1068 {
1069 action=landhold2; FFCore.setHeroAction(landhold2);
1070 break;
1071 }
1072
1073 default:
1074 if(charging) //!DIMITODO: Let Hero jump while charging sword
1075 {
1076 reset_swordcharge();
1077 attackclk=0;
1078 }
1079
1080 break;
1081 }
1082 }
1083
1084 fakez=(new_z>0 ? new_z : zfix(0));
1085 }
1086
1087 64458 void HeroClass::setFall(zfix new_fall)
1088 {
1089 64458 fall=new_fall;
1090 64458 justmoved = 2;
1091 64458 jumping=-1;
1092 64458 }
1093 void HeroClass::setFakeFall(zfix new_fall)
1094 {
1095 fakefall=new_fall;
1096 jumping=-1;
1097 }
1098 void HeroClass::setClimbCoverX(int32_t new_x)
1099 {
1100 climb_cover_x=new_x;
1101 }
1102 void HeroClass::setClimbCoverY(int32_t new_y)
1103 {
1104 climb_cover_y=new_y;
1105 }
1106 43693 int32_t HeroClass::getLStep()
1107 {
1108 43693 return lstep;
1109 }
1110 3678 int32_t HeroClass::getCharging()
1111 {
1112 3678 return charging;
1113 }
1114 59928 bool HeroClass::isCharged()
1115 {
1116 59928 return spins>0;
1117 }
1118 int32_t HeroClass::getAttackClk()
1119 {
1120 return attackclk;
1121 }
1122 void HeroClass::setAttackClk(int32_t new_clk)
1123 {
1124 attackclk=new_clk;
1125 }
1126 void HeroClass::setCharging(int32_t new_charging)
1127 {
1128 charging=new_charging;
1129 }
1130 2835315624 int32_t HeroClass::getSwordClk()
1131 {
1132 2835315624 return swordclk;
1133 }
1134 2806231585 int32_t HeroClass::getItemClk()
1135 {
1136 2806231585 return itemclk;
1137 }
1138 6 void HeroClass::setSwordClk(int32_t newclk)
1139 {
1140 6 swordclk=newclk;
1141 6 verifyAWpn();
1142 6 }
1143 108 void HeroClass::setItemClk(int32_t newclk)
1144 {
1145 108 itemclk=newclk;
1146 108 }
1147 // TODO remove, no longer needed.
1148 697113 zfix HeroClass::getModifiedX()
1149 {
1150 697113 zfix tempx=x;
1151 697113 return tempx;
1152 }
1153
1154 697113 zfix HeroClass::getModifiedY()
1155 {
1156 697113 zfix tempy=y;
1157 697113 return tempy;
1158 }
1159
1160 18253 int32_t HeroClass::getDir()
1161 {
1162 18253 return dir;
1163 }
1164 31148 void HeroClass::setDir(int32_t newdir)
1165 {
1166 31148 dir=newdir;
1167 31148 reset_hookshot();
1168 31148 }
1169 int32_t HeroClass::getHitDir()
1170 {
1171 return hitdir;
1172 }
1173 void HeroClass::setHitDir(int32_t newdir)
1174 {
1175 hitdir = newdir;
1176 }
1177 int32_t HeroClass::getClk()
1178 {
1179 return clk;
1180 }
1181 int32_t HeroClass::getPushing()
1182 {
1183 return pushing;
1184 }
1185 8597 void HeroClass::Catch()
1186 {
1187
5/6
✓ Branch 0 taken 8597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6528 times.
✓ Branch 3 taken 2069 times.
✓ Branch 4 taken 3662 times.
✓ Branch 5 taken 2866 times.
8597 if(!inwallm && (action==none || action==walking))
1188 {
1189 5731 SetAttack();
1190 5731 attackclk=0;
1191 5731 attack=wCatching;
1192 5731 }
1193 8597 }
1194
1195 5166365 bool HeroClass::getClock()
1196 {
1197 5166365 return superman;
1198 }
1199 768 void HeroClass::setClock(bool state)
1200 {
1201 768 superman=state;
1202 768 }
1203 41955440 int32_t HeroClass::getAction() // Used by ZScript
1204 {
1205
2/2
✓ Branch 0 taken 7632 times.
✓ Branch 1 taken 41947808 times.
41955440 if(spins > 0)
1206 7632 return isspinning;
1207
2/2
✓ Branch 0 taken 17289 times.
✓ Branch 1 taken 41930519 times.
41947808 else if(charging > 0)
1208 17289 return ischarging;
1209
2/2
✓ Branch 0 taken 41893595 times.
✓ Branch 1 taken 36924 times.
41930519 else if(diveclk > 0)
1210 36924 return isdiving;
1211 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1212
1213 41893595 return action;
1214 41955440 }
1215
1216 27427511 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1217 {
1218
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 27426663 times.
27427511 if(spins > 0)
1219 848 return isspinning;
1220
2/2
✓ Branch 0 taken 1921 times.
✓ Branch 1 taken 27424742 times.
27426663 else if(charging > 0)
1221 1921 return ischarging;
1222
2/2
✓ Branch 0 taken 27330854 times.
✓ Branch 1 taken 93888 times.
27424742 else if(diveclk > 0)
1223 93888 return isdiving;
1224 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1225
1226 27330854 return -1;
1227 27427511 }
1228
1229 392 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1230 {
1231
4/8
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 392 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 392 times.
784 if(new_action==dying || new_action==won || new_action==scrolling ||
1232
3/6
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 392 times.
✗ Branch 5 not taken.
392 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1233 392 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1234 return; // Can't use these actions.
1235
1236
3/6
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 193 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
392 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1237 return;
1238
1239
1/2
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
392 if(new_action==rafting)
1240 {
1241 if(get_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING)) return;
1242 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1243 return;
1244 }
1245
1246
1247
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(magicitem>-1 && itemsbuf[magicitem].family==itype_divineescape)
1248 {
1249 // Using Divine Escape
1250 if(magiccastclk<96)
1251 {
1252 // Not cast yet; cancel it
1253 magicitem=-1;
1254 magiccastclk=0;
1255 }
1256 else
1257 // Already activated; don't do anything
1258 return;
1259 }
1260
1261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
392 if(action==inwind) // Remove from whirlwind
1262 {
1263 xofs=0;
1264 whirlwind=0;
1265 lstep=0;
1266 if ( dontdraw < 2 ) { dontdraw=0; }
1267 }
1268
2/4
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392 times.
392 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1269 {
1270 sprite* wind=0;
1271 bool foundWind=false;
1272 for(int32_t i=0; i<Ewpns.Count(); i++)
1273 {
1274 wind=Ewpns.spr(i);
1275 if(wind->id==ewWind && wind->misc==999)
1276 {
1277 foundWind=true;
1278 break;
1279 }
1280 }
1281
1282 if(foundWind)
1283 {
1284 xofs=0;
1285 if ( dontdraw < 2 ) { dontdraw=false; }
1286 wind->misc=-1;
1287 x=wind->x;
1288 y=wind->y;
1289 }
1290 }
1291
1292 //Unless compat rule is on, reset hopping clocks when writing action!
1293
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(action == hopping && !get_bit(quest_rules,qr_NO_OVERWRITING_HOPPING))
1294 {
1295 hopclk = 0;
1296 hopdir = -1;
1297 }
1298
1299
3/4
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267 times.
392 if(new_action != attacking && new_action != sideswimattacking)
1300 {
1301 267 attackclk=0;
1302
1303
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(attack==wHookshot)
1304 reset_hookshot();
1305 267 }
1306
2/4
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392 times.
392 if(new_action != isspinning && new_action != sideswimisspinning)
1307 {
1308 392 charging = 0;
1309 392 spins = 0;
1310 392 }
1311
1312
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if(action == falling && new_action != falling)
1313 {
1314 fallclk = 0; //Stop falling;
1315 }
1316
1317
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
392 if (action == rafting && new_action != rafting)
1318 {
1319 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1320 raftwarpy = y;
1321 }
1322
1323
2/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 267 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
392 switch(new_action)
1324 {
1325 case isspinning:
1326 case sideswimisspinning:
1327 if(attack==wSword)
1328 {
1329 attackclk = SWORDCHARGEFRAME+1;
1330 charging = 0;
1331
1332 if(spins==0)
1333 spins = 5;
1334 }
1335 return;
1336
1337 case isdiving:
1338 if(action==swimming && diveclk==0)
1339 {
1340 int32_t flippers_id = current_item_id(itype_flippers);
1341 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1342 }
1343 return;
1344
1345 case drowning:
1346 case sidedrowning:
1347 //I would add a sanity check to see if Hero is in water, but I *KNOW* that quests have used this
1348 // INTENTIONALLY while Hero is on Land, as a blink-out effect. :( -Z
1349 if(!drownclk)
1350 Drown();
1351
1352 break;
1353
1354 case lavadrowning:
1355 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1356 if(!drownclk)
1357 Drown(1);
1358
1359 break;
1360
1361 case falling:
1362 if(!fallclk)
1363 {
1364 //If there is a pit under Hero, use it's combo.
1365 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1366 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1367 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1368 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1369 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1370 //Else, use a null value; triggers default pit values
1371 else fallCombo = 0;
1372 fallclk = PITFALL_FALL_FRAMES;
1373 }
1374 break;
1375
1376 case gothit:
1377 case swimhit:
1378 case sideswimhit:
1379 if(!hclk)
1380 hclk=48;
1381
1382 break;
1383
1384 case landhold1:
1385 case landhold2:
1386 case waterhold1:
1387 case waterhold2:
1388 case sidewaterhold1:
1389 case sidewaterhold2:
1390 if(!holdclk)
1391 holdclk=130;
1392
1393 attack=none;
1394 break;
1395
1396 case attacking:
1397 case sideswimattacking:
1398 125 attack=none;
1399 125 break;
1400
1401 default:
1402 267 break;
1403 }
1404
1405 392 action=new_action; FFCore.setHeroAction(new_action);
1406 392 }
1407
1408 void HeroClass::setHeldItem(int32_t newitem)
1409 {
1410 holditem=newitem;
1411 }
1412 17 int32_t HeroClass::getHeldItem()
1413 {
1414 17 return holditem;
1415 }
1416 6174060 bool HeroClass::isDiving()
1417 {
1418 6174060 int32_t flippers_id = current_item_id(itype_flippers);
1419
2/2
✓ Branch 0 taken 4512057 times.
✓ Branch 1 taken 1662003 times.
6174060 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1420 }
1421 13641157 bool HeroClass::isSwimming()
1422 {
1423
4/6
✓ Branch 0 taken 13499485 times.
✓ Branch 1 taken 141672 times.
✓ Branch 2 taken 13499485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13499485 times.
✗ Branch 5 not taken.
27140642 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1424
4/4
✓ Branch 0 taken 13498055 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 390 times.
✓ Branch 3 taken 13497665 times.
13499485 (action==waterhold1)||(action==waterhold2)||
1425 13497665 (hopclk==0xFF));
1426 }
1427
1428 771 void HeroClass::setDontDraw(byte new_dontdraw)
1429 {
1430 771 dontdraw=new_dontdraw;
1431 771 }
1432
1433 569512 byte HeroClass::getDontDraw()
1434 {
1435 569512 return dontdraw;
1436 }
1437
1438 void HeroClass::setHClk(int32_t newhclk)
1439 {
1440 hclk=newhclk;
1441 }
1442
1443 87306 int32_t HeroClass::getHClk()
1444 {
1445 87306 return hclk;
1446 }
1447
1448 4168756 int32_t HeroClass::getSpecialCave()
1449 {
1450 4168756 return specialcave; // used only by maps.cpp
1451 }
1452
1453 335 void HeroClass::init()
1454 {
1455 335 usecounts.clear();
1456 335 scale = 0;
1457 335 rotation = 0;
1458 335 do_animation = 1;
1459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 335 times.
335 if(lift_wpn)
1460 {
1461 delete lift_wpn;
1462 lift_wpn = nullptr;
1463 }
1464 335 liftclk = 0;
1465 335 tliftclk = 0;
1466 335 liftheight = 0;
1467 335 liftflags = 0;
1468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 335 times.
335 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1469 335 hookshot_used=false;
1470 335 justmoved = 0;
1471 335 hookshot_frozen=false;
1472 335 onpassivedmg=false;
1473 335 dir = up;
1474 335 damageovertimeclk = 0;
1475 335 newconveyorclk = 0;
1476 335 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1477
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 335 times.
2680 for(auto q = 0; q < 7; ++q)
1478 2345 hooked_undercombos[q] = -1;
1479 335 shiftdir = -1;
1480 335 sideswimdir = right;
1481 335 holddir = -1;
1482 335 landswim = 0;
1483 335 sdir = up;
1484 335 ilswim=true;
1485 335 walkable=false;
1486 335 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1487 335 warp_sound = 0;
1488 335 subscr_speed = zinit.subscrSpeed;
1489 335 steprate = zinit.heroStep;
1490 335 is_warping = false;
1491 335 coyotetime = 0;
1492
1493 335 hammer_swim_up_offset = hammeroffsets[0];
1494 335 hammer_swim_down_offset = hammeroffsets[1];
1495 335 hammer_swim_left_offset = hammeroffsets[2];
1496 335 hammer_swim_right_offset = hammeroffsets[3];
1497
1498 335 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1499
1500
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 237 times.
335 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
1501 {
1502 98 x=tmpscr->warpreturnx[0];
1503 98 y=tmpscr->warpreturny[0];
1504 98 }
1505 else
1506 {
1507 237 x=tmpscr->warparrivalx;
1508 237 y=tmpscr->warparrivaly;
1509 }
1510
1511 335 z=fakez=fall=fakefall=0;
1512 335 hzsz = 12; // So that flying peahats can still hit him.
1513
1514
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 269 times.
335 if(x==0) dir=right;
1515
1516
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 334 times.
335 if(x==240) dir=left;
1517
1518
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 262 times.
335 if(y==0) dir=down;
1519
1520
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 241 times.
335 if(y==160) dir=up;
1521
1522 335 lstep=0;
1523 335 skipstep=0;
1524 335 autostep=false;
1525 335 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1526 335 attack=wNone;
1527 335 attackid=-1;
1528 335 action=none; FFCore.setHeroAction(none); tempaction=none;
1529 335 xofs=0;
1530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 335 times.
335 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1531 335 cs=6;
1532 335 pushing=fairyclk=0;
1533 335 id=0;
1534 335 inlikelike=0;
1535 335 superman=inwallm=false;
1536 335 scriptcoldet=1;
1537 335 blowcnt=whirlwind=specialcave=0;
1538 335 hopclk=diveclk=fallclk=0;
1539 335 fallCombo = 0;
1540 335 pit_pulldir = -1;
1541 335 hopdir=-1;
1542 335 conveyor_flags=0;
1543 335 drunkclk=0;
1544 335 lstunclock = 0;
1545 335 is_conveyor_stunned=0;
1546 335 convey_forcex=convey_forcey=0;
1547 335 drawstyle=3;
1548 335 ffwarp = false;
1549 335 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1550 335 stepnext=stepsecret=-1;
1551 335 ffpit = false;
1552 335 respawn_x=x;
1553 335 respawn_y=y;
1554 335 respawn_dmap=currdmap;
1555 335 respawn_scr=currscr;
1556 335 falling_oldy = y;
1557 335 magiccastclk=0;
1558 335 magicitem = div_prot_item = -1;
1559 335 last_lens_id = 0; //Should be -1 (-Z)
1560 335 last_savepoint_id = 0;
1561 335 misc_internal_hero_flags = 0;
1562 335 last_cane_of_byrna_item_id = -1;
1563 335 on_sideview_ladder = false;
1564 335 switchblock_z = 0;
1565 335 switchblock_offset = false;
1566 335 extra_jump_count = 0;
1567 335 hoverflags = 0;
1568 335 lbunnyclock = 0;
1569
1570
2/2
✓ Branch 0 taken 10720 times.
✓ Branch 1 taken 335 times.
11055 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1571
1572 335 setBigHitbox(get_bit(quest_rules, qr_LTTPCOLLISION));
1573 335 diagonalMovement=(get_bit(quest_rules,qr_LTTPWALK));
1574
1575 335 shield_active = false;
1576 335 shield_forcedir = -1;
1577 335 active_shield_id = -1;
1578
1579 //2.6
1580 335 preventsubscreenfalling = false; //-Z
1581 335 walkspeed = 0; //not used, yet. -Z
1582
2/2
✓ Branch 0 taken 5695 times.
✓ Branch 1 taken 335 times.
6030 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1583
2/2
✓ Branch 0 taken 5695 times.
✓ Branch 1 taken 335 times.
6030 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1584
2/2
✓ Branch 0 taken 48910 times.
✓ Branch 1 taken 335 times.
49245 for ( int32_t q = 0; q < wMax; q++ )
1585 {
1586 48910 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1587 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1588 48910 }
1589 //Run script!
1590
4/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 303 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 17 times.
335 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1591 {
1592 15 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT, SCRIPT_PLAYER_INIT);
1593 15 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT);
1594 15 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1595 15 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1596 //are properly set by the engine.
1597 15 }
1598 335 FFCore.nostepforward = 0;
1599
1600
4/4
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 236 times.
335 if (!replay_is_active() || replay_get_version() >= 12)
1601 99 z3step = 2;
1602 335 }
1603
1604 7285159 void HeroClass::draw_under(BITMAP* dest)
1605 {
1606 7285159 int32_t c_raft=current_item_id(itype_raft);
1607 7285159 int32_t c_ladder=current_item_id(itype_ladder);
1608
1609
3/4
✓ Branch 0 taken 80476 times.
✓ Branch 1 taken 7204683 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80476 times.
7285159 if(action==rafting && c_raft >-1)
1610 {
1611
4/4
✓ Branch 0 taken 59051 times.
✓ Branch 1 taken 21425 times.
✓ Branch 2 taken 41054 times.
✓ Branch 3 taken 39422 times.
80476 if(((dir==left) || (dir==right)) && (get_bit(quest_rules,qr_RLFIX)))
1612 {
1613 78844 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1614 39422 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1615 39422 }
1616 else
1617 {
1618 82108 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1619 41054 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1620 }
1621 80476 }
1622
1623
3/4
✓ Branch 0 taken 97855 times.
✓ Branch 1 taken 7187304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97855 times.
7285159 if(ladderx+laddery && c_ladder >-1)
1624 {
1625
4/4
✓ Branch 0 taken 44432 times.
✓ Branch 1 taken 53423 times.
✓ Branch 2 taken 26065 times.
✓ Branch 3 taken 18367 times.
97855 if((ladderdir>=left) && (get_bit(quest_rules,qr_RLFIX)))
1626 {
1627 52130 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1628 26065 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1629 26065 }
1630 else
1631 {
1632 143580 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1633 71790 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1634 }
1635 97855 }
1636 7285159 }
1637
1638 3721 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1639 {
1640 3721 int32_t tempy=yofs;
1641 3721 yofs+=8;
1642 3721 shadowtile = wpnsbuf[spr_shadow].tile;
1643 3721 sprite::drawshadow(dest,translucent);
1644 3721 yofs=tempy;
1645 3721 }
1646
1647 // The Stone of Agony reacts to these flags.
1648 487612 bool HeroClass::agonyflag(int32_t flag)
1649 {
1650
2/2
✓ Branch 0 taken 487580 times.
✓ Branch 1 taken 32 times.
487612 switch(flag)
1651 {
1652 case mfWHISTLE:
1653 case mfANYFIRE:
1654 case mfARROW:
1655 case mfBOMB:
1656 case mfSBOMB:
1657 case mfBRANG:
1658 case mfMBRANG:
1659 case mfFBRANG:
1660 case mfSARROW:
1661 case mfGARROW:
1662 case mfSTRONGFIRE:
1663 case mfMAGICFIRE:
1664 case mfDIVINEFIRE:
1665 case mfWANDMAGIC:
1666 case mfREFMAGIC:
1667 case mfREFFIREBALL:
1668 case mfSWORD:
1669 case mfWSWORD:
1670 case mfMSWORD:
1671 case mfXSWORD:
1672 case mfSWORDBEAM:
1673 case mfWSWORDBEAM:
1674 case mfMSWORDBEAM:
1675 case mfXSWORDBEAM:
1676 case mfHOOKSHOT:
1677 case mfWAND:
1678 case mfHAMMER:
1679 case mfSTRIKE:
1680 32 return true;
1681 }
1682
1683 487580 return false;
1684 487612 }
1685
1686
1687 // Find the attack power of the current melee weapon.
1688 // The Whimsical Ring is applied on a target-by-target basis.
1689 469074 int32_t HeroClass::weaponattackpower(int32_t itid)
1690 {
1691
1/2
✓ Branch 0 taken 469074 times.
✗ Branch 1 not taken.
469074 if(itid < 0)
1692 {
1693 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1694 : attack==wWand ? itype_wand
1695 : attack==wHammer ? itype_hammer
1696 : itype_sword);
1697 }
1698
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 469054 times.
469074 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1699
1700 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1701
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 468500 times.
469074 if(spins > 0)
1702 {
1703 574 int scr = currentscroll;
1704
1/2
✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
574 if(scr < 0)
1705 {
1706 scr = current_item_id(attack==wHammer ? (spins>1?itype_quakescroll2:itype_quakescroll)
1707 : (spins>5 || current_item_id(itype_spinscroll) < 0)
1708 ? itype_spinscroll2 : itype_spinscroll);
1709 }
1710 574 power *= itemsbuf[scr].power;
1711 574 }
1712 468500 else currentscroll = -1;
1713 469074 return power;
1714 }
1715
1716 #define NET_CLK_TOTAL 24
1717 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1718 // Must only be called once per frame!
1719 void HeroClass::positionNet(weapon *w, int32_t itemid)
1720 {
1721 itemid = vbound(itemid, 0, MAXITEMS-1);
1722 int32_t t = w->o_tile,
1723 wx = 1, wy = 1;
1724
1725 //Invert positioning clock if right-handed animation
1726 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1727 if(clock >= NET_CLK_TOTAL)
1728 w->dead = 0;
1729 int32_t tiledir = dir;
1730 switch(dir)
1731 {
1732 case up:
1733 {
1734 if(clock < NET_DIR_INC) tiledir = l_up;
1735 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1736 break;
1737 }
1738 case down:
1739 {
1740 if(clock < NET_DIR_INC) tiledir = r_down;
1741 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1742 break;
1743 }
1744 case left:
1745 {
1746 if(clock < NET_DIR_INC) tiledir = l_down;
1747 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1748 break;
1749 }
1750 case right:
1751 {
1752 if(clock < NET_DIR_INC) tiledir = r_up;
1753 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1754 break;
1755 }
1756 }
1757 int32_t offs = 0;
1758 if(tiledir > right)
1759 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1760 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1761 //One of 8 positions
1762 switch(tiledir)
1763 {
1764 case up:
1765 {
1766 wx = 6*offs;
1767 wy = -14;
1768 break;
1769 }
1770 case r_up:
1771 {
1772 wx = (offs ? 10 : 14);
1773 wy = (offs ? -12 : -10);
1774 break;
1775 }
1776 case right:
1777 {
1778 wx = 14;
1779 wy = 6*offs;
1780 break;
1781 }
1782 case r_down:
1783 {
1784 wx = (offs ? 14 : 10);
1785 wy = (offs ? 10 : 12);
1786 break;
1787 }
1788 case down:
1789 {
1790 wx = -6*offs;
1791 wy = 14;
1792 break;
1793 }
1794 case l_down:
1795 {
1796 wx = (offs ? -10 : -14);
1797 wy = (offs ? 12 : 10);
1798 break;
1799 }
1800 case left:
1801 {
1802 wx = -14;
1803 wy = -6*offs;
1804 break;
1805 }
1806 case l_up:
1807 {
1808 wx = (offs ? -14 : -10);
1809 wy = (offs ? -10 : -12);
1810 break;
1811 }
1812 }
1813
1814 w->x = x+wx;
1815 w->y = y+wy-(54-(yofs))-fakez;
1816 w->z = (z+zofs);
1817 w->fakez = fakez;
1818 w->tile = t+tiledir;
1819 w->power = 0;
1820 w->dir = dir;
1821 w->doAutoRotate(true);
1822 }
1823 412628 void HeroClass::positionSword(weapon *w, int32_t itemid)
1824 {
1825 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
1826 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
1827 412628 itemid=vbound(itemid, 0, MAXITEMS-1);
1828 // Place a sword weapon at the right spot.
1829 412628 int32_t wy=1;
1830 412628 int32_t wx=1;
1831 412628 int32_t f=0,t,cs2;
1832
1833 412628 t = w->o_tile;
1834 412628 cs2 = w->o_cset;
1835 412628 slashxofs=0;
1836 412628 slashyofs=0;
1837
1838
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 94214 times.
✓ Branch 2 taken 89955 times.
✓ Branch 3 taken 113144 times.
✓ Branch 4 taken 115315 times.
412628 switch(dir)
1839 {
1840 case up:
1841 94214 wx=-1;
1842 94214 wy=-12;
1843
1844
7/8
✓ Branch 0 taken 6693 times.
✓ Branch 1 taken 87521 times.
✓ Branch 2 taken 5640 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 5230 times.
✓ Branch 5 taken 410 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5230 times.
94214 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1845 {
1846
2/2
✓ Branch 0 taken 3418 times.
✓ Branch 1 taken 1812 times.
5230 if(attackclk>10) //extended stab
1847 {
1848 1812 slashyofs-=3;
1849 1812 wy-=2;
1850 1812 }
1851
1852
2/2
✓ Branch 0 taken 4778 times.
✓ Branch 1 taken 452 times.
5230 if(attackclk>=14) //retracting stab
1853 {
1854 452 slashyofs+=3;
1855 452 wy+=2;
1856 452 }
1857 5230 }
1858 else
1859 {
1860
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 88698 times.
88984 if(attackclk==SWORDCHARGEFRAME)
1861 {
1862 286 wy+=4;
1863 286 }
1864
2/2
✓ Branch 0 taken 8612 times.
✓ Branch 1 taken 80086 times.
88698 else if(attackclk==13)
1865 {
1866 8612 wy+=4;
1867 8612 }
1868
2/2
✓ Branch 0 taken 71572 times.
✓ Branch 1 taken 8514 times.
80086 else if(attackclk==14)
1869 {
1870 8514 wy+=8;
1871 8514 }
1872 }
1873
1874 94214 break;
1875
1876 case down:
1877 89955 f=get_bit(quest_rules,qr_SWORDWANDFLIPFIX)?3:2;
1878 89955 wy=11;
1879
1880
7/8
✓ Branch 0 taken 9260 times.
✓ Branch 1 taken 80695 times.
✓ Branch 2 taken 8503 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 8143 times.
✓ Branch 5 taken 360 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8143 times.
89955 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1881 {
1882
2/2
✓ Branch 0 taken 5288 times.
✓ Branch 1 taken 2855 times.
8143 if(attackclk>10) //extended stab
1883 {
1884 2855 slashyofs+=3;
1885 2855 wy+=2;
1886 2855 }
1887
1888
2/2
✓ Branch 0 taken 7441 times.
✓ Branch 1 taken 702 times.
8143 if(attackclk>=14) //retracting stab
1889 {
1890 702 slashyofs-=3;
1891 702 wy-=2;
1892 702 }
1893 8143 }
1894 else
1895 {
1896
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 81212 times.
81812 if(attackclk==SWORDCHARGEFRAME)
1897 {
1898 600 wy-=2;
1899 600 }
1900
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 73220 times.
81212 else if(attackclk==13)
1901 {
1902 7992 wy-=4;
1903 7992 }
1904
2/2
✓ Branch 0 taken 65256 times.
✓ Branch 1 taken 7964 times.
73220 else if(attackclk==14)
1905 {
1906 7964 wy-=8;
1907 7964 }
1908 }
1909
1910 89955 break;
1911
1912 case left:
1913 113144 f=1;
1914 113144 wx=-11;
1915 113144 ++t;
1916
1917
7/8
✓ Branch 0 taken 12751 times.
✓ Branch 1 taken 100393 times.
✓ Branch 2 taken 10433 times.
✓ Branch 3 taken 2318 times.
✓ Branch 4 taken 9581 times.
✓ Branch 5 taken 852 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9581 times.
113144 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1918 {
1919
2/2
✓ Branch 0 taken 6140 times.
✓ Branch 1 taken 3441 times.
9581 if(attackclk>10) //extended stab
1920 {
1921 3441 slashxofs-=4;
1922 3441 wx-=7;
1923 3441 }
1924
1925
2/2
✓ Branch 0 taken 8726 times.
✓ Branch 1 taken 855 times.
9581 if(attackclk>=14) //retracting stab
1926 {
1927 855 slashxofs+=3;
1928 855 wx+=7;
1929 855 }
1930 9581 }
1931 else
1932 {
1933
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 103360 times.
103563 if(attackclk==SWORDCHARGEFRAME)
1934 {
1935 203 wx+=2;
1936 203 }
1937
2/2
✓ Branch 0 taken 10192 times.
✓ Branch 1 taken 93168 times.
103360 else if(attackclk==13)
1938 {
1939 10192 wx+=4;
1940 10192 }
1941
2/2
✓ Branch 0 taken 83012 times.
✓ Branch 1 taken 10156 times.
93168 else if(attackclk==14)
1942 {
1943 10156 wx+=8;
1944 10156 }
1945 }
1946
1947 113144 break;
1948
1949 case right:
1950 115315 wx=11;
1951 115315 ++t;
1952
1953
7/8
✓ Branch 0 taken 12948 times.
✓ Branch 1 taken 102367 times.
✓ Branch 2 taken 11071 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 9237 times.
✓ Branch 5 taken 1834 times.
✓ Branch 6 taken 9237 times.
✗ Branch 7 not taken.
115315 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1954 {
1955
2/2
✓ Branch 0 taken 5924 times.
✓ Branch 1 taken 3313 times.
9237 if(attackclk>10) //extended stab
1956 {
1957 3313 slashxofs+=4;
1958 3313 wx+=7;
1959 3313 }
1960
1961
2/2
✓ Branch 0 taken 8410 times.
✓ Branch 1 taken 827 times.
9237 if(attackclk>=14) //retracting stab
1962 {
1963 827 slashxofs-=3;
1964 827 wx-=7;
1965 827 }
1966 9237 }
1967 else
1968 {
1969
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 105483 times.
106078 if(attackclk==SWORDCHARGEFRAME)
1970 {
1971 595 wx-=2;
1972 595 }
1973
2/2
✓ Branch 0 taken 10375 times.
✓ Branch 1 taken 95108 times.
105483 else if(attackclk==13)
1974 {
1975 10375 wx-=4;
1976 10375 }
1977
2/2
✓ Branch 0 taken 84760 times.
✓ Branch 1 taken 10348 times.
95108 else if(attackclk==14)
1978 {
1979 10348 wx-=8;
1980 10348 }
1981 }
1982
1983 115315 break;
1984 }
1985
1986
6/6
✓ Branch 0 taken 41652 times.
✓ Branch 1 taken 370976 times.
✓ Branch 2 taken 32211 times.
✓ Branch 3 taken 9441 times.
✓ Branch 4 taken 11429 times.
✓ Branch 5 taken 20782 times.
412628 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
1987 {
1988 20782 int32_t wpn2=itemsbuf[itemid].wpn2;
1989 20782 wpn2=vbound(wpn2, 0, MAXWPNS);
1990
1991 //slashing tiles
1992
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3418 times.
✓ Branch 2 taken 5294 times.
✓ Branch 3 taken 6140 times.
✓ Branch 4 taken 5930 times.
20782 switch(dir)
1993 {
1994 case up:
1995 3418 wx=15;
1996 3418 wy=-3;
1997 3418 ++t;
1998 3418 f=0; //starts pointing right
1999
2000
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 1885 times.
3418 if(attackclk>=7)
2001 {
2002 1885 wy-=9;
2003 1885 wx-=3;
2004 1885 t = wpnsbuf[wpn2].tile;
2005 1885 cs2 = wpnsbuf[wpn2].csets&15;
2006 1885 f=0;
2007 1885 }
2008
2009 3418 break;
2010
2011 case down:
2012 5294 wx=-13;
2013 5294 wy=-1;
2014 5294 ++t;
2015 5294 f=1; //starts pointing left
2016
2017
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 2990 times.
5294 if(attackclk>=7)
2018 {
2019 2990 wy+=15;
2020 2990 wx+=2;
2021 2990 t = wpnsbuf[wpn2].tile;
2022 2990 cs2 = wpnsbuf[wpn2].csets&15;
2023 2990 ++t;
2024 2990 f=0;
2025 2990 }
2026
2027 5294 break;
2028
2029 case left:
2030 6140 wx=3;
2031 6140 wy=-15;
2032 6140 --t;
2033 6140 f=0; //starts pointing up
2034
2035
2/2
✓ Branch 0 taken 2658 times.
✓ Branch 1 taken 3482 times.
6140 if(attackclk>=7)
2036 {
2037 3482 wx-=15;
2038 3482 wy+=3;
2039 3482 slashxofs-=1;
2040 3482 t = wpnsbuf[wpn2].tile;
2041 3482 cs2 = wpnsbuf[wpn2].csets&15;
2042 3482 t+=2;
2043 3482 f=0;
2044 3482 }
2045
2046 6140 break;
2047
2048 case right:
2049 5930 --t;
2050
2051
2/4
✓ Branch 0 taken 5930 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5930 times.
5930 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2052 {
2053 wx=1;
2054 wy=13;
2055 f=2;
2056 }
2057 else
2058 {
2059 5930 wx=3;
2060 5930 wy=-15;
2061 5930 f=0;
2062 }
2063
2064
2/2
✓ Branch 0 taken 2579 times.
✓ Branch 1 taken 3351 times.
5930 if(attackclk>=7)
2065 {
2066 3351 wx+=15;
2067 3351 slashxofs+=1;
2068 3351 t = wpnsbuf[wpn2].tile;
2069 3351 cs2 = wpnsbuf[wpn2].csets&15;
2070
2071
2/4
✓ Branch 0 taken 3351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3351 times.
3351 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2072 {
2073 wx-=1;
2074 wy-=2;
2075 }
2076 else
2077 {
2078 3351 t+=3;
2079 3351 f=0;
2080 3351 wy+=3;
2081 }
2082 3351 }
2083
2084 5930 break;
2085 }
2086 20782 }
2087
2088 412628 int32_t itemid2 = current_item_id(itype_chargering);
2089
2090
4/4
✓ Branch 0 taken 21741 times.
✓ Branch 1 taken 390887 times.
✓ Branch 2 taken 412096 times.
✓ Branch 3 taken 532 times.
412628 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2091 {
2092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2093 532 }
2094
2095 /*if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2096 {
2097 wy+=2;
2098 }*/
2099 412628 w->x = x+wx;
2100 412628 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2101 412628 w->z = (z+zofs);
2102 412628 w->tile = t;
2103 412628 w->flip = f;
2104 412628 w->power = weaponattackpower(itemid);
2105 412628 w->dir = dir;
2106 412628 w->doAutoRotate(true);
2107 412628 }
2108
2109 int HeroClass::getHammerState() const
2110 {
2111 if(attack == wHammer)
2112 {
2113 if(attackclk >= 15)
2114 return 3;
2115 if(attackclk >= 13)
2116 return 2;
2117 return 1;
2118 }
2119 return 0;
2120 }
2121
2122 7325492 void HeroClass::draw(BITMAP* dest)
2123 {
2124 /*{
2125 char buf[36];
2126 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2127 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2128 }*/
2129 7325492 int32_t oxofs = xofs, oyofs = yofs;
2130 7325492 bool shieldModify = false;
2131
2/2
✓ Branch 0 taken 7308384 times.
✓ Branch 1 taken 17108 times.
7325492 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2132
2133 {
2134
2/2
✓ Branch 0 taken 3241 times.
✓ Branch 1 taken 7322251 times.
7325492 if(action==dying)
2135 {
2136
2/2
✓ Branch 0 taken 2526 times.
✓ Branch 1 taken 715 times.
3241 if(!invisible)
2137 {
2138
1/2
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
715 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2139 715 sprite::draw(dest);
2140 715 }
2141 3241 goto herodraw_end;
2142 }
2143
2144 7322251 bool useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2145
2146
2147
2/2
✓ Branch 0 taken 73318 times.
✓ Branch 1 taken 7248933 times.
7322251 if(!invisible)
2148
6/6
✓ Branch 0 taken 6291279 times.
✓ Branch 1 taken 957654 times.
✓ Branch 2 taken 3992931 times.
✓ Branch 3 taken 2298348 times.
✓ Branch 4 taken 170808 times.
✓ Branch 5 taken 3822123 times.
7248933 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2149
2150 // Stone of Agony
2151 7322251 bool agony=false;
2152 7322251 int32_t agonyid = current_item_id(itype_agony);
2153
2154
2/2
✓ Branch 0 taken 73318 times.
✓ Branch 1 taken 7248933 times.
7322251 if(!invisible)
2155 {
2156
2/2
✓ Branch 0 taken 7005119 times.
✓ Branch 1 taken 243814 times.
7248933 if(agonyid>-1)
2157 {
2158 243814 int32_t power=itemsbuf[agonyid].power;
2159 243814 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2160 243814 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2161 243814 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2162 243814 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2163
2164
2/2
✓ Branch 0 taken 243814 times.
✓ Branch 1 taken 243814 times.
487628 for(int32_t x=left; x<right; x+=16)
2165 {
2166
2/2
✓ Branch 0 taken 243782 times.
✓ Branch 1 taken 243814 times.
487596 for(int32_t y=top; y<bottom; y+=16)
2167 {
2168
4/4
✓ Branch 0 taken 243798 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 243782 times.
243814 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2169 {
2170 32 agony=true;
2171 32 x=right; // Break out of outer loop
2172 32 break;
2173 }
2174 243782 }
2175 243814 }
2176 243814 }
2177
2178 7248933 cs = 6;
2179
1/2
✓ Branch 0 taken 7248933 times.
✗ Branch 1 not taken.
7248933 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2180
2/2
✓ Branch 0 taken 1301062 times.
✓ Branch 1 taken 5947871 times.
7248933 if(!get_bit(quest_rules,qr_HEROFLICKER))
2181 {
2182
3/4
✓ Branch 0 taken 96072 times.
✓ Branch 1 taken 5851799 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96072 times.
5947871 if(superman && getCanFlicker())
2183 {
2184 96072 cs += (((~frame)>>1)&3);
2185 96072 }
2186
4/6
✓ Branch 0 taken 239290 times.
✓ Branch 1 taken 5612509 times.
✓ Branch 2 taken 239290 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 239290 times.
5851799 else if(hclk&&(DivineProtectionShieldClk<=0) && getCanFlicker())
2187 {
2188 239290 cs += ((hclk>>1)&3);
2189 239290 }
2190 5947871 }
2191 7248933 }
2192
2193
5/6
✓ Branch 0 taken 6550269 times.
✓ Branch 1 taken 771982 times.
✓ Branch 2 taken 6544467 times.
✓ Branch 3 taken 5802 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6544467 times.
7322251 if(attackclk || (action==attacking||action==sideswimattacking))
2194 {
2195 /* Spaghetti code constants!
2196 * - Hero.attack contains a weapon type...
2197 * - which must be converted to an itype...
2198 * - which must be converted to an item ID...
2199 * - which is used to acquire a wpn ID! Aack!
2200 */
2201
8/8
✓ Branch 0 taken 12859 times.
✓ Branch 1 taken 764925 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 764897 times.
✓ Branch 4 taken 21498 times.
✓ Branch 5 taken 743399 times.
✓ Branch 6 taken 22079 times.
✓ Branch 7 taken 721320 times.
777784 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2202
4/4
✓ Branch 0 taken 29427 times.
✓ Branch 1 taken 748357 times.
✓ Branch 2 taken 907 times.
✓ Branch 3 taken 28520 times.
777784 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2203 777784 itemid=vbound(itemid, 0, MAXITEMS-1);
2204 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2205
7/8
✓ Branch 0 taken 250868 times.
✓ Branch 1 taken 526916 times.
✓ Branch 2 taken 250868 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162452 times.
✓ Branch 5 taken 88416 times.
✓ Branch 6 taken 13522 times.
✓ Branch 7 taken 148930 times.
777784 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2206 {
2207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540438 times.
540438 if(attack == wBugNet)
2208 {
2209 weapon *w=NULL;
2210 bool found = false;
2211 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2212 {
2213 w = (weapon*)Lwpns.spr(q);
2214 if(w->id == wBugNet)
2215 {
2216 found = true;
2217 break;
2218 }
2219 }
2220 if(!found)
2221 {
2222 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2223
2224 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2225 }
2226 positionNet(w, itemid);
2227 }
2228
8/8
✓ Branch 0 taken 133070 times.
✓ Branch 1 taken 407368 times.
✓ Branch 2 taken 117716 times.
✓ Branch 3 taken 15354 times.
✓ Branch 4 taken 108841 times.
✓ Branch 5 taken 8875 times.
✓ Branch 6 taken 117696 times.
✓ Branch 7 taken 422742 times.
540438 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2229 {
2230 // Create a sword weapon at the right spot.
2231 422742 weapon *w=NULL;
2232 422742 bool found = false;
2233
2234 // Look for pre-existing sword
2235
2/2
✓ Branch 0 taken 41309 times.
✓ Branch 1 taken 488537 times.
529846 for(int32_t i=0; i<Lwpns.Count(); i++)
2236 {
2237 488537 w = (weapon*)Lwpns.spr(i);
2238
2239
2/2
✓ Branch 0 taken 107104 times.
✓ Branch 1 taken 381433 times.
488537 if(w->id == (attack==wSword ? wSword : wWand))
2240 {
2241 381433 found = true;
2242 381433 break;
2243 }
2244 107104 }
2245
2246
2/2
✓ Branch 0 taken 381433 times.
✓ Branch 1 taken 41309 times.
422742 if(!found) // Create one if sword nonexistant
2247 {
2248
5/10
✓ Branch 0 taken 41309 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41309 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41309 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41309 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 41309 times.
✗ Branch 9 not taken.
41309 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2249 41309 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2250
2251 41309 positionSword(w,itemid);
2252
2253 // Stone of Agony
2254
1/2
✓ Branch 0 taken 41309 times.
✗ Branch 1 not taken.
41309 if(agony)
2255 {
2256 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2257 }
2258 41309 }
2259
2260 // These are set by positionSword(), above or in checkstab()
2261 422742 yofs += slashyofs;
2262 422742 xofs += slashxofs;
2263 422742 slashyofs = slashxofs = 0;
2264 422742 }
2265 540438 }
2266
2267 777784 if(attackclk<7
2268
4/4
✓ Branch 0 taken 412164 times.
✓ Branch 1 taken 365620 times.
✓ Branch 2 taken 313895 times.
✓ Branch 3 taken 98269 times.
777784 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2269
4/6
✓ Branch 0 taken 72650 times.
✓ Branch 1 taken 241245 times.
✓ Branch 2 taken 72650 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72650 times.
313895 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2270
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 70837 times.
72650 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2271
4/4
✓ Branch 0 taken 158442 times.
✓ Branch 1 taken 10664 times.
✓ Branch 2 taken 151559 times.
✓ Branch 3 taken 6883 times.
170919 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2272
4/4
✓ Branch 0 taken 12929 times.
✓ Branch 1 taken 156177 times.
✓ Branch 2 taken 17518 times.
✓ Branch 3 taken 138659 times.
169106 || (attack==wHammer && attackclk<=30)
2273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138659 times.
156177 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2274 {
2275
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 639042 times.
639125 if(!invisible)
2276 {
2277 639042 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2278
2/4
✓ Branch 0 taken 639042 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 639042 times.
✗ Branch 3 not taken.
639042 if (FIXED_Z3_ANIMATION)
2279 {
2280 if (attackclk >= 2) tile += (extend==2?2:1);
2281 if (attackclk >= 13) tile += (extend==2?2:1);
2282 }
2283
2284
14/18
✓ Branch 0 taken 58722 times.
✓ Branch 1 taken 580320 times.
✓ Branch 2 taken 13042 times.
✓ Branch 3 taken 45680 times.
✓ Branch 4 taken 5786 times.
✓ Branch 5 taken 7256 times.
✓ Branch 6 taken 4967 times.
✓ Branch 7 taken 819 times.
✓ Branch 8 taken 41282 times.
✓ Branch 9 taken 17440 times.
✓ Branch 10 taken 23091 times.
✓ Branch 11 taken 18191 times.
✓ Branch 12 taken 23091 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 23091 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
639042 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2285 {
2286 18191 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2287
2/4
✓ Branch 0 taken 18191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18191 times.
✗ Branch 3 not taken.
18191 if (FIXED_Z3_ANIMATION)
2288 {
2289 if (attackclk >= 7) tile += (extend==2?2:1);
2290 if (attackclk >= 11) tile += (extend==2?2:1);
2291 if (attackclk >= 14) tile += (extend==2?2:1);
2292 }
2293 18191 }
2294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 639042 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
639042 if (attack==wBugNet && !get_bit(quest_rules, qr_OLD_BUG_NET))
2295 {
2296 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2297 {
2298 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2299 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2300 }
2301 else
2302 {
2303 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2304 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2305 }
2306 }
2307
2308
4/4
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 616963 times.
✓ Branch 2 taken 13029 times.
✓ Branch 3 taken 9050 times.
639042 if((attack==wHammer) && (attackclk<13))
2309 {
2310 9050 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2311
2/4
✓ Branch 0 taken 9050 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9050 times.
✗ Branch 3 not taken.
9050 if (FIXED_Z3_ANIMATION)
2312 {
2313 if (attackclk >= 14) tile += (extend==2?2:1);
2314 if (attackclk >= 16) tile += (extend==2?2:1);
2315 }
2316 9050 }
2317
2318
2/2
✓ Branch 0 taken 586541 times.
✓ Branch 1 taken 52501 times.
639042 if(useltm)
2319 {
2320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52501 times.
52501 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2321 52501 }
2322
2323 // Stone of Agony
2324
1/2
✓ Branch 0 taken 639042 times.
✗ Branch 1 not taken.
639042 if(agony)
2325 {
2326 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2327 }
2328
2329 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2330
2331 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2332
6/6
✓ Branch 0 taken 137706 times.
✓ Branch 1 taken 501336 times.
✓ Branch 2 taken 134100 times.
✓ Branch 3 taken 3606 times.
✓ Branch 4 taken 11476 times.
✓ Branch 5 taken 126230 times.
639042 if (!(get_bit(quest_rules, qr_HEROFLICKER) && ((superman || hclk) && (frame & 1))))
2333 {
2334 627566 masked_draw(dest);
2335 627566 }
2336
2337 //Prevent flickering -Z
2338
1/2
✓ Branch 0 taken 639042 times.
✗ Branch 1 not taken.
639042 if (!getCanFlicker()) masked_draw(dest);
2339 639042 }
2340
2341
2/2
✓ Branch 0 taken 617046 times.
✓ Branch 1 taken 22079 times.
639125 if(attack!=wHammer)
2342 617046 goto herodraw_end;
2343 22079 }
2344
2345
2/2
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 138659 times.
160738 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2346 {
2347 22079 int32_t wy=1;
2348 22079 int32_t wx=1;
2349 22079 int32_t f=0,t,cs2;
2350 22079 weapon *w=NULL;
2351 22079 bool found = false;
2352
2353
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 21549 times.
22314 for(int32_t i=0; i<Lwpns.Count(); i++)
2354 {
2355 21549 w = (weapon*)Lwpns.spr(i);
2356
2357
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 21314 times.
21549 if(w->id == wHammer)
2358 {
2359 21314 found = true;
2360 21314 break;
2361 }
2362 235 }
2363
2364
2/2
✓ Branch 0 taken 21314 times.
✓ Branch 1 taken 765 times.
22079 if(!found)
2365 {
2366
5/10
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 765 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 765 times.
✗ Branch 9 not taken.
765 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2367 765 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2368 765 found = true;
2369 765 }
2370
2371 22079 t = w->o_tile;
2372 22079 cs2 = w->o_cset;
2373
2374
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3412 times.
✓ Branch 2 taken 4870 times.
✓ Branch 3 taken 6386 times.
✓ Branch 4 taken 7411 times.
22079 switch(dir)
2375 {
2376 case up:
2377 3412 wx=-1;
2378 3412 wy=-15;
2379
1/2
✓ Branch 0 taken 3412 times.
✗ Branch 1 not taken.
3412 if (IsSideSwim())wy+=hammer_swim_up_offset;
2380
2381
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 2010 times.
3412 if(attackclk>=13)
2382 {
2383 2010 wx-=1;
2384 2010 wy+=1;
2385 2010 ++t;
2386 2010 }
2387
2388
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1778 times.
3412 if(attackclk>=15)
2389 {
2390
1/2
✓ Branch 0 taken 1778 times.
✗ Branch 1 not taken.
1778 if (IsSideSwim())wy-=hammer_swim_up_offset;
2391 1778 ++t;
2392 1778 }
2393
2394 3412 break;
2395
2396 case down:
2397 4870 wx=3;
2398 4870 wy=-14;
2399
1/2
✓ Branch 0 taken 4870 times.
✗ Branch 1 not taken.
4870 if (IsSideSwim())wy+=hammer_swim_down_offset;
2400 4870 t+=3;
2401
2402
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 2849 times.
4870 if(attackclk>=13)
2403 {
2404 2849 wy+=16;
2405 2849 ++t;
2406 2849 }
2407
2408
2/2
✓ Branch 0 taken 2344 times.
✓ Branch 1 taken 2526 times.
4870 if(attackclk>=15)
2409 {
2410 2526 wx-=1;
2411 2526 wy+=12;
2412
1/2
✓ Branch 0 taken 2526 times.
✗ Branch 1 not taken.
2526 if (IsSideSwim())wy-=hammer_swim_down_offset;
2413 2526 ++t;
2414 2526 }
2415
2416 4870 break;
2417
2418 case left:
2419 6386 wx=0;
2420 6386 wy=-14;
2421
1/2
✓ Branch 0 taken 6386 times.
✗ Branch 1 not taken.
6386 if (IsSideSwim())wy+=hammer_swim_left_offset;
2422 6386 t+=6;
2423 6386 f=1;
2424
2425
2/2
✓ Branch 0 taken 2562 times.
✓ Branch 1 taken 3824 times.
6386 if(attackclk>=13)
2426 {
2427 3824 wx-=7;
2428 3824 wy+=8;
2429 3824 ++t;
2430 3824 }
2431
2432
2/2
✓ Branch 0 taken 2986 times.
✓ Branch 1 taken 3400 times.
6386 if(attackclk>=15)
2433 {
2434 3400 wx-=8;
2435 3400 wy+=8;
2436
1/2
✓ Branch 0 taken 3400 times.
✗ Branch 1 not taken.
3400 if (IsSideSwim())wy-=hammer_swim_left_offset;
2437 3400 ++t;
2438 3400 }
2439
2440 6386 break;
2441
2442 case right:
2443 7411 wx=0;
2444 7411 wy=-14;
2445
1/2
✓ Branch 0 taken 7411 times.
✗ Branch 1 not taken.
7411 if (IsSideSwim())wy+=hammer_swim_right_offset;
2446 7411 t+=6;
2447
2448
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 4346 times.
7411 if(attackclk>=13)
2449 {
2450 4346 wx+=7;
2451 4346 wy+=8;
2452 4346 ++t;
2453 4346 }
2454
2455
2/2
✓ Branch 0 taken 3558 times.
✓ Branch 1 taken 3853 times.
7411 if(attackclk>=15)
2456 {
2457 3853 wx+=8;
2458 3853 wy+=8;
2459
1/2
✓ Branch 0 taken 3853 times.
✗ Branch 1 not taken.
3853 if (IsSideSwim())wy-=hammer_swim_right_offset;
2460 3853 ++t;
2461 3853 }
2462
2463 7411 break;
2464 }
2465
2466
7/8
✓ Branch 0 taken 21929 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 18085 times.
✓ Branch 3 taken 3844 times.
✓ Branch 4 taken 18085 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1927 times.
✓ Branch 7 taken 16158 times.
22079 if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2467 {
2468 16308 wy+=2;
2469 16308 }
2470
2471 // Stone of Agony
2472
1/2
✓ Branch 0 taken 22079 times.
✗ Branch 1 not taken.
22079 if(agony)
2473 {
2474 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2475 }
2476
2477 22079 w->x = x+wx;
2478 22079 w->y = y+wy-(54-yofs)-fakez;
2479 22079 w->z = (z+zofs);
2480 22079 w->tile = t;
2481 22079 w->flip = f;
2482 22079 w->hxsz=20;
2483 22079 w->hysz=20;
2484
2485
2/2
✓ Branch 0 taken 13797 times.
✓ Branch 1 taken 8282 times.
22079 if(dir>down)
2486 {
2487 13797 w->hysz-=6;
2488 13797 }
2489 else
2490 {
2491 8282 w->hxsz-=6;
2492 8282 w->hyofs=4;
2493 }
2494
2495 22079 w->power = weaponattackpower(itemid);
2496
2497
7/10
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 21345 times.
✓ Branch 2 taken 734 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 734 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 732 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
22079 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2498 {
2499
3/4
✓ Branch 0 taken 722 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 734 times.
✗ Branch 3 not taken.
734 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_bit(quest_rules,qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2500 734 }
2501
2502 22079 goto herodraw_end;
2503 }
2504 138659 }
2505
2/4
✓ Branch 0 taken 6544467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6544467 times.
6544467 else if(!charging && !spins) // remove the sword
2506 {
2507
2/2
✓ Branch 0 taken 1720460 times.
✓ Branch 1 taken 6544467 times.
8264927 for(int32_t i=0; i<Lwpns.Count(); i++)
2508 {
2509 1720460 weapon *w = (weapon*)Lwpns.spr(i);
2510
2511
6/6
✓ Branch 0 taken 1719686 times.
✓ Branch 1 taken 774 times.
✓ Branch 2 taken 1719576 times.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 17390 times.
✓ Branch 5 taken 1702186 times.
1720460 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2512 18274 w->dead=1;
2513 1720460 }
2514 6544467 }
2515
2516
2/2
✓ Branch 0 taken 73235 times.
✓ Branch 1 taken 6609891 times.
6683126 if(invisible)
2517 {
2518 73235 goto herodraw_end;
2519 }
2520
2521
2/4
✓ Branch 0 taken 6609891 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6609891 times.
6609891 if(action != casting && action != sideswimcasting)
2522 {
2523 // Keep this consistent with checkspecial2, line 7800-ish...
2524
6/6
✓ Branch 0 taken 156151 times.
✓ Branch 1 taken 6453740 times.
✓ Branch 2 taken 149362 times.
✓ Branch 3 taken 6789 times.
✓ Branch 4 taken 7237 times.
✓ Branch 5 taken 142125 times.
6609891 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2525
2526 6609891 int32_t jumping2 = int32_t(jumping*((zinit.gravity2 / 100)/16.0));
2527 6609891 bool noliftspr = get_bit(quest_rules,qr_NO_LIFT_SPRITE);
2528 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2529
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6152249 times.
✓ Branch 3 taken 457642 times.
6609891 switch(zinit.heroAnimationStyle)
2530 {
2531 case las_original: //normal
2532
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 6152185 times.
6152249 if(action==drowning)
2533 {
2534
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(inwater)
2535 {
2536 64 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2538 64 }
2539 else
2540 {
2541 goto herodraw_end;
2542 }
2543 64 }
2544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6152185 times.
6152185 else if(action==lavadrowning)
2545 {
2546 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2547 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2548 }
2549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6152185 times.
6152185 else if(action==sidedrowning)
2550 {
2551 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2552 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2553 }
2554
2/4
✓ Branch 0 taken 6152185 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6152185 times.
6152185 else if (action == sideswimming || action == sideswimhit)
2555 {
2556 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2557
2558 if(lstep>=6)
2559 {
2560 if(dir==up)
2561 {
2562 if ( script_hero_sprite <= 0 ) ++flip;
2563 }
2564 else
2565 {
2566 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2567 }
2568 }
2569 }
2570
5/6
✓ Branch 0 taken 6080748 times.
✓ Branch 1 taken 71437 times.
✓ Branch 2 taken 6080228 times.
✓ Branch 3 taken 520 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6080228 times.
6152185 else if(action==swimming || action==swimhit || hopclk==0xFF)
2571 {
2572 71957 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2573
2574
2/2
✓ Branch 0 taken 35932 times.
✓ Branch 1 taken 36025 times.
71957 if(lstep>=6)
2575 {
2576
2/2
✓ Branch 0 taken 7125 times.
✓ Branch 1 taken 28900 times.
36025 if(dir==up)
2577 {
2578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7125 times.
7125 if ( script_hero_sprite <= 0 ) ++flip;
2579 7125 }
2580 else
2581 {
2582
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28900 times.
28900 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2583 }
2584 36025 }
2585
2586
2/2
✓ Branch 0 taken 68768 times.
✓ Branch 1 taken 3189 times.
71957 if(isDiving())
2587 {
2588 3189 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3189 times.
3189 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2590 3189 }
2591 71957 }
2592
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 6078610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
6080228 else if(charging > 0 && attack != wHammer)
2593 {
2594 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2595
2596
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2597 {
2598
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2599 {
2600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( script_hero_sprite <= 0 ) ++flip;
2601 144 }
2602 else
2603 {
2604
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2605 }
2606 675 }
2607 1618 }
2608
9/12
✓ Branch 0 taken 6078368 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 6078368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85805 times.
✓ Branch 5 taken 5992805 times.
✓ Branch 6 taken 71761 times.
✓ Branch 7 taken 14044 times.
✓ Branch 8 taken 71761 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 71761 times.
6078610 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2609 {
2610 71761 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71761 times.
71761 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2612 71761 }
2613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6006849 times.
6006849 else if(fallclk>0)
2614 {
2615 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2616 if ( script_hero_sprite <= 0 ) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2617 }
2618
3/6
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 6006233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 616 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6006849 else if(!noliftspr&&action==lifting&&isLifting())
2619 {
2620 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2621 if(script_hero_sprite <= 0)
2622 {
2623 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2624 auto speed = tliftclk/frames;
2625 if (speed < 1) speed = 1;
2626 auto curframe = (tliftclk - liftclk) / speed;
2627 if (!tliftclk) curframe = frames - 1;
2628 if(unsigned(curframe) < frames)
2629 tile += curframe * (extend == 2 ? 2 : 1);
2630 }
2631 }
2632 else
2633 {
2634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6006849 times.
6006849 if(IsSideSwim())
2635 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2636
3/4
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 6006233 times.
✓ Branch 2 taken 616 times.
✗ Branch 3 not taken.
6006849 else if(!noliftspr&&isLifting())
2637 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2638 6006849 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2639
2640
2/2
✓ Branch 0 taken 4495469 times.
✓ Branch 1 taken 1511380 times.
6006849 if(dir>up)
2641 {
2642 4495469 useltm=true;
2643 4495469 shieldModify=true;
2644 4495469 }
2645
2646
2/2
✓ Branch 0 taken 2932163 times.
✓ Branch 1 taken 3074686 times.
6006849 if(lstep>=6)
2647 {
2648
2/2
✓ Branch 0 taken 763979 times.
✓ Branch 1 taken 2310707 times.
3074686 if(dir==up)
2649 {
2650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763979 times.
763979 if ( script_hero_sprite <= 0 ) ++flip;
2651 763979 }
2652 else
2653 {
2654
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2310707 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2310707 times.
2310707 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2655 }
2656 3074686 }
2657 }
2658
2659 6152249 break;
2660
2661 case las_bszelda: //BS
2662
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 457066 times.
457642 if(action==drowning)
2663 {
2664
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if(inwater)
2665 {
2666 576 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2668 576 }
2669 else
2670 {
2671 goto herodraw_end;
2672 }
2673 576 }
2674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457066 times.
457066 else if (action == sidedrowning)
2675 {
2676 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2677 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2678 }
2679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457066 times.
457066 else if(action==lavadrowning)
2680 {
2681 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2682 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2683 }
2684
2/4
✓ Branch 0 taken 457066 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 457066 times.
457066 else if (action == sideswimming || action == sideswimhit)
2685 {
2686 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2687
2688 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2689 }
2690
4/6
✓ Branch 0 taken 454300 times.
✓ Branch 1 taken 2766 times.
✓ Branch 2 taken 454300 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 454300 times.
457066 else if(action==swimming || action==swimhit || hopclk==0xFF)
2691 {
2692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2766 times.
2766 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2693 {
2694 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2695 }
2696 else
2697 {
2698 2766 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2699 }
2700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2766 times.
2766 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2701
2702
2/2
✓ Branch 0 taken 2405 times.
✓ Branch 1 taken 361 times.
2766 if(isDiving())
2703 {
2704
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2705 {
2706 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2707 }
2708 else
2709 {
2710 361 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2711 }
2712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 361 times.
361 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2713 361 }
2714 2766 }
2715
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454300 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
454300 else if(charging > 0 && attack != wHammer)
2716 {
2717 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2718 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2719 }
2720
8/10
✓ Branch 0 taken 450821 times.
✓ Branch 1 taken 3479 times.
✓ Branch 2 taken 450821 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3048 times.
✓ Branch 5 taken 451252 times.
✓ Branch 6 taken 2437 times.
✓ Branch 7 taken 611 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2437 times.
454300 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2721 {
2722 2437 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2437 times.
2437 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2724 2437 }
2725
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 451653 times.
451863 else if(fallclk>0)
2726 {
2727 210 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if ( script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2729 210 }
2730
5/6
✓ Branch 0 taken 29043 times.
✓ Branch 1 taken 422610 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 28934 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 109 times.
451653 else if(!noliftspr&&action==lifting&&isLifting())
2731 {
2732 109 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(script_hero_sprite <= 0)
2734 {
2735 109 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2736 109 auto speed = tliftclk/frames;
2737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (speed < 1) speed = 1;
2738 109 auto curframe = (tliftclk - liftclk) / speed;
2739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (!tliftclk) curframe = frames - 1;
2740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(unsigned(curframe) < frames)
2741 109 tile += curframe * (extend == 2 ? 2 : 1);
2742 109 }
2743 109 }
2744 else
2745 {
2746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 451544 times.
451544 if(IsSideSwim())
2747 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2748
4/4
✓ Branch 0 taken 28934 times.
✓ Branch 1 taken 422610 times.
✓ Branch 2 taken 28541 times.
✓ Branch 3 taken 393 times.
451544 else if(!noliftspr&&isLifting())
2749 393 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2750 451151 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2751
2752
2/2
✓ Branch 0 taken 135506 times.
✓ Branch 1 taken 316038 times.
451544 if(dir>up)
2753 {
2754 316038 useltm=true;
2755 316038 shieldModify=true;
2756 316038 }
2757
2758 /*
2759 else if (dir==up)
2760 {
2761 useltm=true;
2762 }
2763 */
2764
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 448984 times.
451544 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2765 }
2766
2767 457642 break;
2768
2769 case las_zelda3slow: //8-frame Zelda 3 (slow)
2770 case las_zelda3: //8-frame Zelda 3
2771 if(action == drowning)
2772 {
2773 if(inwater)
2774 {
2775 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2776 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2777 }
2778 else
2779 {
2780 goto herodraw_end;
2781 }
2782 }
2783 else if(action == lavadrowning)
2784 {
2785 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2786 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2787
2788 }
2789 else if(action == sidedrowning)
2790 {
2791 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2792 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2793 }
2794 else if (action == sideswimming || action == sideswimhit)
2795 {
2796 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2797
2798 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2799 }
2800 else if(action == swimming || action==swimhit || hopclk==0xFF)
2801 {
2802 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2803 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2804
2805 if(isDiving())
2806 {
2807 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2808 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2809 }
2810 }
2811 else if(charging > 0 && attack != wHammer)
2812 {
2813 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2814 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2815 //int32_t l=hero_count/hero_animation_speed;
2816 int32_t l=(hero_count/hero_animation_speed)&15;
2817 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2818 l-=((l>3)?1:0)+((l>12)?1:0);
2819 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2820 }
2821 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2822 {
2823 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2824 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2825 }
2826 else if(fallclk>0)
2827 {
2828 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2829 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2830 }
2831 else if(!noliftspr&&action==lifting&&isLifting())
2832 {
2833 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2834 if(script_hero_sprite <= 0)
2835 {
2836 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2837 auto speed = tliftclk/frames;
2838 if (speed < 1) speed = 1;
2839 auto curframe = (tliftclk-liftclk)/speed;
2840 if (!tliftclk) curframe = frames - 1;
2841 if(unsigned(curframe) < frames)
2842 tile += curframe * (extend == 2 ? 2 : 1);
2843 }
2844 }
2845 else
2846 {
2847 if(IsSideSwim())
2848 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2849 else if(!noliftspr&&isLifting())
2850 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2851 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2852
2853 if(action == walking || action == climbcoverbottom || action == climbcovertop)
2854 {
2855 if (script_hero_sprite <= 0 ) tile += (extend == 2 ? 2 : 1);
2856 }
2857
2858 if(dir>up)
2859 {
2860 useltm=true;
2861 shieldModify=true;
2862 }
2863
2864 if(action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop)
2865 {
2866 //tile+=(extend==2?2:1);
2867 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
2868 int32_t l = hero_count / hero_animation_speed;
2869 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
2870 if (script_hero_sprite <= 0 ) tile += (l / 2) * (extend == 2 ? 2 : 1);
2871 }
2872 }
2873
2874 break;
2875
2876 default:
2877 break;
2878 }
2879 6609891 }
2880
2881
6/6
✓ Branch 0 taken 5704738 times.
✓ Branch 1 taken 905153 times.
✓ Branch 2 taken 3536816 times.
✓ Branch 3 taken 2167922 times.
✓ Branch 4 taken 158886 times.
✓ Branch 5 taken 3377930 times.
6609891 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2882
2883
2/2
✓ Branch 0 taken 6606954 times.
✓ Branch 1 taken 2937 times.
6609891 if(action==won)
2884 {
2885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2937 times.
2937 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
2886 2937 }
2887
2888
4/4
✓ Branch 0 taken 6564472 times.
✓ Branch 1 taken 45419 times.
✓ Branch 2 taken 48991 times.
✓ Branch 3 taken 6515481 times.
6609891 if(action==landhold1 || action==landhold2)
2889 {
2890 94410 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2891
6/6
✓ Branch 0 taken 80134 times.
✓ Branch 1 taken 14276 times.
✓ Branch 2 taken 59609 times.
✓ Branch 3 taken 20525 times.
✓ Branch 4 taken 13567 times.
✓ Branch 5 taken 46042 times.
94410 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2892 94410 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
2893 94410 }
2894
4/4
✓ Branch 0 taken 6514831 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 6514701 times.
6515481 else if(action==waterhold1 || action==waterhold2)
2895 {
2896 780 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2897 780 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
2898 780 }
2899
2/4
✓ Branch 0 taken 6514701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6514701 times.
6514701 else if(action==sidewaterhold1 || action==sidewaterhold2)
2900 {
2901 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2902 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
2903 }
2904
2905
2/4
✓ Branch 0 taken 6609891 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6609891 times.
6609891 if(action!=casting && action!=sideswimcasting)
2906 {
2907
2/2
✓ Branch 0 taken 1583566 times.
✓ Branch 1 taken 5026325 times.
6609891 if(useltm)
2908 {
2909
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 5023765 times.
5026325 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
2910 5026325 }
2911 6609891 }
2912
2913 // Stone of Agony
2914
2/2
✓ Branch 0 taken 6609859 times.
✓ Branch 1 taken 32 times.
6609891 if(agony)
2915 {
2916
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2917 32 }
2918
2919
6/6
✓ Branch 0 taken 1163356 times.
✓ Branch 1 taken 5446535 times.
✓ Branch 2 taken 1108839 times.
✓ Branch 3 taken 54517 times.
✓ Branch 4 taken 59060 times.
✓ Branch 5 taken 1104296 times.
6609891 if(!(get_bit(quest_rules,qr_HEROFLICKER)&&((superman||hclk)&&(frame&1))))
2920 {
2921 6550831 masked_draw(dest);
2922 6550831 }
2923
2924 //draw held items after Hero so they don't go behind his head
2925
4/4
✓ Branch 0 taken 6564472 times.
✓ Branch 1 taken 45419 times.
✓ Branch 2 taken 48991 times.
✓ Branch 3 taken 6515481 times.
6609891 if(action==landhold1 || action==landhold2)
2926 {
2927
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 94394 times.
94410 if(holditem > -1)
2928 {
2929
2/2
✓ Branch 0 taken 44580 times.
✓ Branch 1 taken 49814 times.
94394 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2930 {
2931 44580 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2932 44580 }
2933 else
2934 {
2935 49814 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2936 }
2937 94394 }
2938 94410 }
2939
4/4
✓ Branch 0 taken 6514831 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 6514701 times.
6515481 else if(action==waterhold1 || action==waterhold2)
2940 {
2941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(holditem > -1)
2942 {
2943
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 260 times.
780 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2944 {
2945 520 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2946 520 }
2947 else
2948 {
2949 260 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2950 }
2951 780 }
2952 780 }
2953
2/4
✓ Branch 0 taken 6514701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6514701 times.
6514701 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
2954 {
2955 if(holditem > -1)
2956 {
2957 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2958 {
2959 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2960 }
2961 else
2962 {
2963 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2964 }
2965 }
2966 }
2967
4/4
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 6593530 times.
✓ Branch 2 taken 3393 times.
✓ Branch 3 taken 12968 times.
6609891 if(fairyclk==0||(get_bit(quest_rules,qr_NOHEARTRING)))
2968 {
2969 6596923 goto herodraw_end;
2970 }
2971
2972 12968 double a2 = fairyclk*int64_t(2)*PI/80 + (PI/2);
2973 12968 int32_t hearts=0;
2974 // int32_t htile = QHeader.dat_flags[ZQ_TILES] ? 2 : 0;
2975 12968 int32_t htile = 2;
2976
2977 12968 do
2978 {
2979 80784 int32_t nx=125;
2980
2981
2/2
✓ Branch 0 taken 56544 times.
✓ Branch 1 taken 24240 times.
80784 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2982 {
2983 24240 nx=x;
2984 24240 }
2985
2986 80784 int32_t ny=88;
2987
2988
2/2
✓ Branch 0 taken 56544 times.
✓ Branch 1 taken 24240 times.
80784 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2989 {
2990 24240 ny=y;
2991 24240 }
2992
2993 80784 double tx = zc::math::Cos(a2)*53 +nx;
2994 80784 double ty = -zc::math::Sin(a2)*53 +ny+playing_field_offset;
2995 80784 overtile8(dest,htile,int32_t(tx),int32_t(ty),1,0);
2996 80784 a2-=PI/4;
2997 80784 ++hearts;
2998
2/2
✓ Branch 0 taken 67816 times.
✓ Branch 1 taken 12968 times.
161568 }
2999
2/2
✓ Branch 0 taken 6560 times.
✓ Branch 1 taken 74224 times.
80784 while(a2>PI/2 && hearts<8);
3000 12968 }
3001 herodraw_end:
3002 7325492 xofs=oxofs;
3003 7325492 yofs=oyofs;
3004 7325492 do_primitives(dest, SPLAYER_PLAYER_DRAW, tmpscr, 0, playing_field_offset);
3005 7325492 }
3006
3007 7178397 void HeroClass::masked_draw(BITMAP* dest)
3008 {
3009 7178397 zfix lz, lfz;
3010
2/2
✓ Branch 0 taken 7177895 times.
✓ Branch 1 taken 502 times.
7178397 if(lift_wpn)
3011 {
3012 502 lz = lift_wpn->z;
3013 502 lfz = lift_wpn->fakez;
3014 502 }
3015
3016
12/12
✓ Branch 0 taken 3956498 times.
✓ Branch 1 taken 3221899 times.
✓ Branch 2 taken 3786476 times.
✓ Branch 3 taken 170022 times.
✓ Branch 4 taken 3736182 times.
✓ Branch 5 taken 50294 times.
✓ Branch 6 taken 3682105 times.
✓ Branch 7 taken 54077 times.
✓ Branch 8 taken 3604662 times.
✓ Branch 9 taken 77443 times.
✓ Branch 10 taken 3642720 times.
✓ Branch 11 taken 143756 times.
7178397 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_bit(quest_rules,qr_FREEFORM))
3017 {
3018 // clip under doorways
3019 143756 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
3020
3021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143756 times.
143756 if(sub!=NULL)
3022 {
3023 143756 yofs -= (playing_field_offset+16);
3024 143756 xofs -= 16;
3025 143756 sprite::draw(sub);
3026
1/2
✓ Branch 0 taken 143756 times.
✗ Branch 1 not taken.
143756 if(lift_wpn)
3027 {
3028 handle_lift(false);
3029 bool shad = lift_wpn->has_shadow;
3030 lift_wpn->has_shadow = false;
3031 lift_wpn->z += z;
3032 lift_wpn->fakez += fakez;
3033 lift_wpn->draw(sub);
3034 lift_wpn->has_shadow = shad;
3035 }
3036 143756 prompt_draw(sub);
3037 143756 xofs+=16;
3038 143756 yofs += (playing_field_offset+16);
3039 143756 destroy_bitmap(sub);
3040 143756 }
3041 143756 }
3042 else
3043 {
3044 7034641 sprite::draw(dest);
3045
2/2
✓ Branch 0 taken 7034139 times.
✓ Branch 1 taken 502 times.
7034641 if(lift_wpn)
3046 {
3047 502 handle_lift(false);
3048 502 bool shad = lift_wpn->has_shadow;
3049 502 lift_wpn->has_shadow = false;
3050 502 lift_wpn->z += z;
3051 502 lift_wpn->fakez += fakez;
3052 502 lift_wpn->draw(dest);
3053 502 lift_wpn->has_shadow = shad;
3054 502 }
3055 7034641 prompt_draw(dest);
3056 }
3057
3058
2/2
✓ Branch 0 taken 7177895 times.
✓ Branch 1 taken 502 times.
7178397 if(lift_wpn)
3059 {
3060 502 lift_wpn->z = lz;
3061 502 lift_wpn->fakez = lfz;
3062 502 }
3063 7178397 return;
3064 }
3065 7178397 void HeroClass::prompt_draw(BITMAP* dest)
3066 {
3067
2/2
✓ Branch 0 taken 7176348 times.
✓ Branch 1 taken 2049 times.
7178397 if(!prompt_combo) return;
3068 2049 int32_t sx = real_x(x+xofs+prompt_x);
3069 2049 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3070 2049 sy -= fake_z(fakez);
3071 2049 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3072 2049 return;
3073 7178397 }
3074
3075 9356 void collectitem_script(int32_t id)
3076 {
3077
2/2
✓ Branch 0 taken 9242 times.
✓ Branch 1 taken 114 times.
9356 if(itemsbuf[id].collect_script)
3078 {
3079 //clear item script stack.
3080 //ri = &(itemScriptData[id]);
3081 //ri->Clear();
3082 //itemCollectScriptData[id].Clear();
3083 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0;
3084 114 ri = &(itemCollectScriptData[id]);
3085
2/2
✓ Branch 0 taken 116736 times.
✓ Branch 1 taken 114 times.
116850 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0xFFFF;
3086 114 ri->Clear();
3087 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id & 0xFFF)*-1));
3088
3089
2/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if ( id > 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3090 {
3091 114 item_collect_doscript[id] = 1;
3092 114 itemscriptInitialised[id] = 0;
3093 114 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id)*-1));
3094 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3095 114 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id));
3096 114 }
3097 else if (id == 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3098 {
3099 item_collect_doscript[id] = 1;
3100 itemscriptInitialised[id] = 0;
3101 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
3102 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3103 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
3104 }
3105 //runningItemScripts[id] = 0;
3106 114 }
3107 9356 }
3108 930 void passiveitem_script(int32_t id, bool doRun = false)
3109 {
3110 //Passive item scripts on colelction
3111
3/6
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 903 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
930 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING)) ))
3112 {
3113 ri = &(itemScriptData[id]);
3114 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id][q] = 0xFFFF;
3115 ri->Clear();
3116 item_doscript[id] = 1;
3117 itemscriptInitialised[id] = 0;
3118
3119
3120 if(get_bit(quest_rules,qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3121 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3122 {
3123 item_doscript[id] = 0;
3124 return;
3125 }
3126 if(doRun)
3127 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].script, id);
3128 }
3129 930 }
3130
3131 // separate case for sword/wand/hammer/slashed weapons only
3132 // the main weapon checking is in the global function check_collisions()
3133 6418199 bool HeroClass::checkstab()
3134 {
3135
14/14
✓ Branch 0 taken 5654822 times.
✓ Branch 1 taken 763377 times.
✓ Branch 2 taken 207362 times.
✓ Branch 3 taken 556015 times.
✓ Branch 4 taken 186080 times.
✓ Branch 5 taken 21282 times.
✓ Branch 6 taken 164001 times.
✓ Branch 7 taken 22079 times.
✓ Branch 8 taken 163973 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 151171 times.
✓ Branch 11 taken 12802 times.
✓ Branch 12 taken 175346 times.
✓ Branch 13 taken 436860 times.
6418199 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3136 763377 || (attackclk<=4))
3137 5981339 return false;
3138
3139 436860 weapon *w=NULL;
3140
3141 436860 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3142 436860 bool found = false;
3143 436860 int32_t melee_weapon_index = 0;
3144 436860 int32_t parentitem=-1;
3145 436860 weapon* meleeweap = nullptr;
3146
2/2
✓ Branch 0 taken 46511 times.
✓ Branch 1 taken 506769 times.
553280 for(int32_t i=0; i<Lwpns.Count(); i++)
3147 {
3148 506769 w = (weapon*)Lwpns.spr(i);
3149
3150
6/6
✓ Branch 0 taken 506731 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 11328 times.
✓ Branch 3 taken 495403 times.
✓ Branch 4 taken 116420 times.
✓ Branch 5 taken 390349 times.
506769 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3151 {
3152 390349 found = true;
3153 390349 melee_weapon_index = i+1;
3154 390349 meleeweap = w;
3155 // Position the sword as Hero slashes with it.
3156
3/4
✓ Branch 0 taken 371319 times.
✓ Branch 1 taken 19030 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 371319 times.
390349 if(w->id!=wHammer&&w->id!=wBugNet)
3157 371319 positionSword(w,w->parentitem);
3158
3159 390349 wx=w->x;
3160 390349 wy=w->y;
3161 390349 wz=w->z;
3162 390349 wxsz = w->hxsz;
3163 390349 wysz = w->hysz;
3164 390349 parentitem = w->parentitem;
3165 390349 break;
3166 }
3167 116420 }
3168
3169
6/6
✓ Branch 0 taken 393835 times.
✓ Branch 1 taken 43025 times.
✓ Branch 2 taken 40543 times.
✓ Branch 3 taken 353292 times.
✓ Branch 4 taken 1806 times.
✓ Branch 5 taken 38737 times.
436860 if(attack==wSword && attackclk>=14 && charging==0)
3170 38737 return false;
3171
3172
2/2
✓ Branch 0 taken 351612 times.
✓ Branch 1 taken 46511 times.
398123 if(!found)
3173 46511 return false;
3174
3175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 351612 times.
351612 if(attack == wFire)
3176 return false;
3177
3178
2/2
✓ Branch 0 taken 332582 times.
✓ Branch 1 taken 19030 times.
351612 if(attack==wHammer)
3179 {
3180
2/2
✓ Branch 0 taken 7473 times.
✓ Branch 1 taken 11557 times.
19030 if(attackclk<15)
3181 {
3182
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1152 times.
✓ Branch 2 taken 1702 times.
✓ Branch 3 taken 2090 times.
✓ Branch 4 taken 2529 times.
7473 switch(w->dir)
3183 {
3184 case up:
3185 1152 wx=x-1;
3186 1152 wy=y-4;
3187 1152 break;
3188
3189 case down:
3190 1702 wx=x+8;
3191 1702 wy=y+28;
3192 1702 break; // This is consistent with 2.10
3193
3194 case left:
3195 2090 wx=x-13;
3196 2090 wy=y+14;
3197 2090 break;
3198
3199 case right:
3200 2529 wx=x+21;
3201 2529 wy=y+14;
3202 2529 break;
3203 }
3204
3205
6/8
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 6732 times.
✓ Branch 2 taken 741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 741 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 739 times.
7473 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3206 {
3207 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3208 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3209 switch(dir)
3210 {
3211 case up:
3212 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3213 break;
3214
3215 case down:
3216 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3217 break;
3218
3219 case left:
3220 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3221 break;
3222
3223 case right:
3224 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3225 break;
3226 }
3227 */
3228 739 }
3229
3230 7473 return false;
3231 }
3232
2/2
✓ Branch 0 taken 10823 times.
✓ Branch 1 taken 734 times.
11557 else if(attackclk==15)
3233 {
3234 // Hammer's reach needs adjusted slightly for backward compatibility
3235
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 114 times.
734 if(w->dir==up)
3236 114 w->hyofs-=1;
3237
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 207 times.
620 else if(w->dir==left)
3238 207 w->hxofs-=2;
3239 734 }
3240 11557 }
3241
3242 // The return of Spaghetti Code Constants!
3243
6/6
✓ Branch 0 taken 13622 times.
✓ Branch 1 taken 330517 times.
✓ Branch 2 taken 318942 times.
✓ Branch 3 taken 11575 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 11557 times.
344139 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3244
3/4
✓ Branch 0 taken 17374 times.
✓ Branch 1 taken 326765 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17374 times.
344139 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3245 344139 itemid = vbound(itemid, 0, MAXITEMS-1);
3246
3247 // The sword offsets aren't based on anything other than what felt about right
3248 // compared to the NES game and what mostly kept it from hitting things that
3249 // should clearly be out of range. They could probably still use more tweaking.
3250 // Don't use 2.10 for reference; it's pretty far off.
3251 // - Saf
3252
3253
6/6
✓ Branch 0 taken 34454 times.
✓ Branch 1 taken 309685 times.
✓ Branch 2 taken 5420 times.
✓ Branch 3 taken 29034 times.
✓ Branch 4 taken 8227 times.
✓ Branch 5 taken 26227 times.
344139 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3254 {
3255
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4253 times.
✓ Branch 2 taken 6662 times.
✓ Branch 3 taken 7800 times.
✓ Branch 4 taken 7512 times.
26227 switch(w->dir)
3256 {
3257 case up:
3258
2/2
✓ Branch 0 taken 2745 times.
✓ Branch 1 taken 1508 times.
4253 if(attackclk<8)
3259 {
3260 1508 wy-=4;
3261 1508 }
3262
3263 4253 break;
3264
3265 case down:
3266 //if(attackclk<8)
3267 {
3268 6662 wy-=2;
3269 }
3270 6662 break;
3271
3272 case left:
3273
3274 //if(attackclk<8)
3275 {
3276 7800 wx+=2;
3277 }
3278
3279 7800 break;
3280
3281 case right:
3282
3283 //if(attackclk<8)
3284 {
3285 7512 wx-=3;
3286 //wy+=((spins>0 || get_bit(quest_rules, qr_SLASHFLIPFIX)) ? -4 : 4);
3287 }
3288
3289 7512 break;
3290 }
3291 26227 }
3292
3293
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 77744 times.
✓ Branch 2 taken 75037 times.
✓ Branch 3 taken 94564 times.
✓ Branch 4 taken 96794 times.
344139 switch(w->dir)
3294 {
3295 case up:
3296 77744 wx+=2;
3297 77744 break;
3298
3299 case down:
3300 75037 break;
3301
3302 case left:
3303 94564 wy-=3;
3304 94564 break;
3305
3306 case right:
3307 96794 wy-=3;
3308 96794 break;
3309 }
3310
3311 344139 wx+=w->hxofs;
3312 344139 wy+=w->hyofs;
3313 344139 wy-=(w->fakez).getInt();
3314
3315
2/2
✓ Branch 0 taken 340961 times.
✓ Branch 1 taken 1702666 times.
2043627 for(int32_t i=0; i<guys.Count(); i++)
3316 {
3317
1/2
✓ Branch 0 taken 1702666 times.
✗ Branch 1 not taken.
1702666 if(attack==wBugNet) break;
3318 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3319
6/6
✓ Branch 0 taken 34365 times.
✓ Branch 1 taken 1668301 times.
✓ Branch 2 taken 33886 times.
✓ Branch 3 taken 479 times.
✓ Branch 4 taken 33242 times.
✓ Branch 5 taken 644 times.
1702980 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3320
5/6
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 1125 times.
✓ Branch 2 taken 1570041 times.
✓ Branch 3 taken 98804 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1668355 times.
1669424 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3321
4/4
✓ Branch 0 taken 47794 times.
✓ Branch 1 taken 1620561 times.
✓ Branch 2 taken 314 times.
✓ Branch 3 taken 47480 times.
1668355 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3322 {
3323 // Checking the whimsical ring for every collision check causes
3324 // an odd bug. It's much more likely to activate on a 0-damage
3325 // weapon, since a 0-damage hit won't make the enemy invulnerable
3326 // to damaging hits in the following frames.
3327
3328 34367 int32_t whimsyid = current_item_id(itype_whimsicalring);
3329
3330 34367 int32_t dmg = weaponattackpower(itemid);
3331
2/2
✓ Branch 0 taken 32458 times.
✓ Branch 1 taken 1909 times.
34367 if(whimsyid>-1)
3332 {
3333
3/4
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1793 times.
✓ Branch 3 taken 116 times.
1909 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3334 116 dmg += current_item_power(itype_whimsicalring);
3335 1793 else whimsyid = -1;
3336 1909 }
3337 34367 int32_t atkringid = current_item_id(itype_atkring);
3338
2/2
✓ Branch 0 taken 34359 times.
✓ Branch 1 taken 8 times.
34367 if(atkringid>-1)
3339 {
3340 8 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3341 8 dmg += itemsbuf[atkringid].misc1; //Additive
3342 8 }
3343
3344 34367 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn,w);
3345 34367 enemy *e = (enemy*)guys.spr(i);
3346
2/2
✓ Branch 0 taken 11723 times.
✓ Branch 1 taken 22644 times.
34367 if (h == -1)
3347 {
3348 22644 e->hitby[HIT_BY_LWEAPON] = melee_weapon_index;
3349 22644 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
3350 22644 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
3351
1/2
✓ Branch 0 taken 22644 times.
✗ Branch 1 not taken.
22644 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
3352 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
3353 22644 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
3354 22644 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
3355 22644 } //temp_hit = true; }
3356 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3357
3358
4/4
✓ Branch 0 taken 22644 times.
✓ Branch 1 taken 11723 times.
✓ Branch 2 taken 22599 times.
✓ Branch 3 taken 45 times.
34367 if(h<0 && whimsyid>-1)
3359 {
3360 45 sfx(itemsbuf[whimsyid].usesound);
3361 45 }
3362
3363
4/4
✓ Branch 0 taken 29804 times.
✓ Branch 1 taken 4563 times.
✓ Branch 2 taken 29710 times.
✓ Branch 3 taken 94 times.
34367 if(h && charging>0)
3364 {
3365 94 attackclk = SWORDTAPFRAME;
3366 94 spins=0;
3367 94 }
3368
3369
8/8
✓ Branch 0 taken 29804 times.
✓ Branch 1 taken 4563 times.
✓ Branch 2 taken 25733 times.
✓ Branch 3 taken 4071 times.
✓ Branch 4 taken 25724 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 25716 times.
34367 if(h && hclk==0 && inlikelike != 1 && !get_bit(quest_rules, qr_DYING_ENEMIES_IGNORE_STUN))
3370 {
3371
2/2
✓ Branch 0 taken 25635 times.
✓ Branch 1 taken 81 times.
25716 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3372 {
3373 81 hithero(i);
3374 81 }
3375 25716 }
3376
3377
2/2
✓ Branch 0 taken 31133 times.
✓ Branch 1 taken 3234 times.
34367 if(h==2)
3378 3234 break;
3379 31133 }
3380 1699488 }
3381
3382
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 344065 times.
688334 if(attack == wBugNet
3383
3/4
✓ Branch 0 taken 344139 times.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 344139 times.
344195 || (parentitem==-1&&!get_bit(quest_rules,qr_NOITEMMELEE))
3384
1/2
✓ Branch 0 taken 344139 times.
✗ Branch 1 not taken.
344139 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3385 {
3386
1/4
✓ Branch 0 taken 344121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
344121 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3387
2/2
✓ Branch 0 taken 344121 times.
✓ Branch 1 taken 88470 times.
432591 for(int32_t j=0; j<items.Count(); j++)
3388 {
3389 88470 item* ptr = (item*)items.spr(j);
3390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88470 times.
88470 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3391 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3392
3393
2/4
✓ Branch 0 taken 88470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88470 times.
✗ Branch 3 not taken.
88470 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3394 continue; //No picking these up unless you have a bottle to fill!
3395
5/6
✓ Branch 0 taken 88443 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17604 times.
✓ Branch 3 taken 70839 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17604 times.
88470 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3396 {
3397
7/8
✓ Branch 0 taken 70839 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 30156 times.
✓ Branch 3 taken 40683 times.
✓ Branch 4 taken 40710 times.
✓ Branch 5 taken 30156 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 40710 times.
70866 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3398 {
3399
6/6
✓ Branch 0 taken 38341 times.
✓ Branch 1 taken 2369 times.
✓ Branch 2 taken 961 times.
✓ Branch 3 taken 37380 times.
✓ Branch 4 taken 38332 times.
✓ Branch 5 taken 2378 times.
79050 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3400
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 37617 times.
✓ Branch 3 taken 723 times.
38341 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3401 {
3402 2378 int32_t pickup = ptr->pickup;
3403 2378 int32_t id2 = ptr->id;
3404 2378 int32_t pstr = ptr->pstring;
3405 2378 int32_t pstr_flags = ptr->pickup_string_flags;
3406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(!dofairy)
3407 {
3408 2378 std::vector<int32_t> &ev = FFCore.eventData;
3409 2378 ev.clear();
3410 2378 ev.push_back(id2*10000);
3411 2378 ev.push_back(pickup*10000);
3412 2378 ev.push_back(pstr*10000);
3413 2378 ev.push_back(pstr_flags*10000);
3414 2378 ev.push_back(0);
3415 2378 ev.push_back(ptr->getUID());
3416 2378 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3417 2378 ev.push_back(w->getUID());
3418
3419 2378 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3420 2378 bool nullify = ev[4] != 0;
3421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(nullify) continue;
3422 2378 id2 = ev[0]/10000;
3423 2378 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3424 2378 pstr = ev[2] / 10000;
3425 2378 pstr_flags = ev[3] / 10000;
3426 2378 }
3427
3428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(pickup&ipONETIME) // set mITEM for one-time-only items
3429 setmapflag(mITEM);
3430
1/2
✓ Branch 0 taken 2378 times.
✗ Branch 1 not taken.
2378 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3431 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3432
3433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2378 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3434 setxmapflag(1<<ptr->pickupexstate);
3435
1/2
✓ Branch 0 taken 2378 times.
✗ Branch 1 not taken.
2378 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3436 {
3437 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3438 hidden_entrance(0, true, false, -5);
3439 }
3440 //!DIMI
3441
3442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
2378 if(dofairy)
3443 {
3444 game->fillBottle(itemsbuf[ptr->id].misc4);
3445 }
3446 else
3447 {
3448 2378 collectitem_script(id2);
3449
3450 2378 getitem(id2, false, true);
3451 }
3452 2378 items.del(j);
3453
3454
2/2
✓ Branch 0 taken 2947 times.
✓ Branch 1 taken 2378 times.
5325 for(int32_t i=0; i<Lwpns.Count(); i++)
3455 {
3456 2947 weapon *w2 = (weapon*)Lwpns.spr(i);
3457
3458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2947 times.
2947 if(w2->dragging==j)
3459 {
3460 w2->dragging=-1;
3461 }
3462
1/2
✓ Branch 0 taken 2947 times.
✗ Branch 1 not taken.
2947 else if(w2->dragging>j)
3463 {
3464 w2->dragging-=1;
3465 }
3466 2947 }
3467
3468
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2378 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2378 if ( (pstr > 0 && pstr < msg_count) )
3469 {
3470 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3471 {
3472 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3473 FFCore.SetItemMessagePlayed(id2);
3474 donewmsg(pstr);
3475 break;
3476 }
3477 }
3478
3479 2378 --j;
3480 2378 }
3481 40710 }
3482 70866 }
3483 88470 }
3484 344121 }
3485
3486
3/4
✓ Branch 0 taken 344121 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 344121 times.
344195 if(attack==wCByrna || attack==wBugNet)
3487 74 return false;
3488
3489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344121 times.
344121 if(meleeweap->no_triggers())
3490 return false;
3491
3492
2/2
✓ Branch 0 taken 318942 times.
✓ Branch 1 taken 25179 times.
344121 if(attack==wSword)
3493 {
3494
2/2
✓ Branch 0 taken 279202 times.
✓ Branch 1 taken 39740 times.
318942 if(attackclk == 6)
3495 {
3496
2/2
✓ Branch 0 taken 6994240 times.
✓ Branch 1 taken 39740 times.
7033980 for(int32_t q=0; q<176; q++)
3497 {
3498 6994240 set_bit(screengrid,q,0);
3499 6994240 set_bit(screengrid_layer[0],q,0);
3500 6994240 set_bit(screengrid_layer[1],q,0);
3501 6994240 }
3502
3503
2/2
✓ Branch 0 taken 635840 times.
✓ Branch 1 taken 39740 times.
675580 for(dword q = MAXFFCS/8; q > 0; --q)
3504 635840 ffcgrid[q-1] = 0;
3505 39740 }
3506
3507
4/4
✓ Branch 0 taken 73311 times.
✓ Branch 1 taken 245631 times.
✓ Branch 2 taken 37261 times.
✓ Branch 3 taken 36050 times.
318942 if(dir==up && ((x.getInt()&15)==0))
3508 {
3509 36050 check_slash_block(wx,wy);
3510 36050 check_slash_block(wx,wy+8);
3511
3512 //layers
3513 36050 check_slash_block_layer(wx,wy,1);
3514 36050 check_slash_block_layer(wx,wy+8,1);
3515 36050 check_slash_block_layer(wx,wy,1);
3516 36050 check_slash_block_layer(wx,wy+8,1);
3517 //2
3518 36050 check_slash_block_layer(wx,wy,2);
3519 36050 check_slash_block_layer(wx,wy+8,2);
3520 36050 check_slash_block_layer(wx,wy,2);
3521 36050 check_slash_block_layer(wx,wy+8,2);
3522 36050 }
3523
8/10
✓ Branch 0 taken 37261 times.
✓ Branch 1 taken 245631 times.
✓ Branch 2 taken 1954 times.
✓ Branch 3 taken 35307 times.
✓ Branch 4 taken 155 times.
✓ Branch 5 taken 1799 times.
✓ Branch 6 taken 155 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 155 times.
282892 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3524 {
3525 37106 check_slash_block(wx,wy);
3526 37106 check_slash_block(wx,wy+8);
3527 37106 check_slash_block(wx+8,wy);
3528 37106 check_slash_block(wx+8,wy+8);
3529 ///layer 1
3530 37106 check_slash_block_layer(wx,wy,1);
3531 37106 check_slash_block_layer(wx,wy+8,1);
3532 37106 check_slash_block_layer(wx+8,wy,1);
3533 37106 check_slash_block_layer(wx+8,wy+8,1);
3534 ///layer 2
3535 37106 check_slash_block_layer(wx,wy,2);
3536 37106 check_slash_block_layer(wx,wy+8,2);
3537 37106 check_slash_block_layer(wx+8,wy,2);
3538 37106 check_slash_block_layer(wx+8,wy+8,2);
3539 37106 }
3540
4/4
✓ Branch 0 taken 70549 times.
✓ Branch 1 taken 248393 times.
✓ Branch 2 taken 33993 times.
✓ Branch 3 taken 36556 times.
318942 if(dir==down && ((x.getInt()&15)==0))
3541 {
3542 36556 check_slash_block(wx,wy+wysz-8);
3543 36556 check_slash_block(wx,wy+wysz);
3544
3545 //layer 1
3546 36556 check_slash_block_layer(wx,wy+wysz-8,1);
3547 36556 check_slash_block_layer(wx,wy+wysz,1);
3548 //layer 2
3549 36556 check_slash_block_layer(wx,wy+wysz-8,2);
3550 36556 check_slash_block_layer(wx,wy+wysz,2);
3551 36556 }
3552
8/10
✓ Branch 0 taken 33993 times.
✓ Branch 1 taken 248393 times.
✓ Branch 2 taken 3466 times.
✓ Branch 3 taken 30527 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 3386 times.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 80 times.
282386 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3553 {
3554 33913 check_slash_block(wx,wy+wysz-8);
3555 33913 check_slash_block(wx,wy+wysz);
3556 33913 check_slash_block(wx+8,wy+wysz-8);
3557 33913 check_slash_block(wx+8,wy+wysz);
3558 //layer 1
3559 33913 check_slash_block_layer(wx,wy+wysz-8,1);
3560 33913 check_slash_block_layer(wx,wy+wysz,1);
3561 33913 check_slash_block_layer(wx+8,wy+wysz-8,1);
3562 33913 check_slash_block_layer(wx+8,wy+wysz,1);
3563 //layer 2
3564 33913 check_slash_block_layer(wx,wy+wysz-8,2);
3565 33913 check_slash_block_layer(wx,wy+wysz,2);
3566 33913 check_slash_block_layer(wx+8,wy+wysz-8,2);
3567 33913 check_slash_block_layer(wx+8,wy+wysz,2);
3568 33913 }
3569
3570
2/2
✓ Branch 0 taken 232767 times.
✓ Branch 1 taken 86175 times.
318942 if(dir==left)
3571 {
3572 86175 check_slash_block(wx,wy+8);
3573 86175 check_slash_block(wx+8,wy+8);
3574 //layer 1
3575 86175 check_slash_block_layer(wx,wy+8,1);
3576 86175 check_slash_block_layer(wx+8,wy+8,1);
3577 //layer 2
3578 86175 check_slash_block_layer(wx,wy+8,2);
3579 86175 check_slash_block_layer(wx+8,wy+8,2);
3580 86175 }
3581
3582
2/2
✓ Branch 0 taken 230035 times.
✓ Branch 1 taken 88907 times.
318942 if(dir==right)
3583 {
3584 88907 check_slash_block(wx+wxsz,wy+8);
3585 88907 check_slash_block(wx+wxsz-8,wy+8);
3586 //layer 1
3587 88907 check_slash_block_layer(wx+wxsz,wy+8,1);
3588 88907 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3589 //layer 2
3590 88907 check_slash_block_layer(wx+wxsz,wy+8,2);
3591 88907 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3592 88907 }
3593 318942 }
3594
2/2
✓ Branch 0 taken 13622 times.
✓ Branch 1 taken 11557 times.
25179 else if(attack==wWand)
3595 {
3596
1/2
✓ Branch 0 taken 13622 times.
✗ Branch 1 not taken.
13622 if(attackclk == 5)
3597 {
3598 for(int32_t q=0; q<176; q++)
3599 {
3600 set_bit(screengrid,q,0);
3601 set_bit(screengrid_layer[0],q,0);
3602 set_bit(screengrid_layer[1],q,0);
3603 }
3604
3605 for(dword q = MAXFFCS/8; q > 0; --q)
3606 ffcgrid[q-1] = 0;
3607 }
3608
3609 // cutable blocks
3610
4/4
✓ Branch 0 taken 2662 times.
✓ Branch 1 taken 10960 times.
✓ Branch 2 taken 1464 times.
✓ Branch 3 taken 1198 times.
13622 if(dir==up && (x.getInt()&15)==0)
3611 {
3612 1198 check_wand_block(wx,wy);
3613 1198 check_wand_block(wx,wy+8);
3614 1198 }
3615
5/10
✓ Branch 0 taken 1464 times.
✓ Branch 1 taken 10960 times.
✓ Branch 2 taken 630 times.
✓ Branch 3 taken 834 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 630 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
12424 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3616 {
3617 1464 check_wand_block(wx,wy);
3618 1464 check_wand_block(wx,wy+8);
3619 1464 check_wand_block(wx+8,wy);
3620 1464 check_wand_block(wx+8,wy+8);
3621 1464 }
3622
3623
4/4
✓ Branch 0 taken 1876 times.
✓ Branch 1 taken 11746 times.
✓ Branch 2 taken 824 times.
✓ Branch 3 taken 1052 times.
13622 if(dir==down && (x.getInt()&15)==0)
3624 {
3625 1052 check_wand_block(wx,wy+wysz-8);
3626 1052 check_wand_block(wx,wy+wysz);
3627 1052 }
3628
5/10
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 11746 times.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 689 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 135 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
12570 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3629 {
3630 824 check_wand_block(wx,wy+wysz-8);
3631 824 check_wand_block(wx,wy+wysz);
3632 824 check_wand_block(wx+8,wy+wysz-8);
3633 824 check_wand_block(wx+8,wy+wysz);
3634 824 }
3635
3636
2/2
✓ Branch 0 taken 8509 times.
✓ Branch 1 taken 5113 times.
13622 if(dir==left)
3637 {
3638 5113 check_wand_block(wx,y+8);
3639 5113 check_wand_block(wx+8,y+8);
3640 5113 }
3641
3642
2/2
✓ Branch 0 taken 9651 times.
✓ Branch 1 taken 3971 times.
13622 if(dir==right)
3643 {
3644 3971 check_wand_block(wx+wxsz,y+8);
3645 3971 check_wand_block(wx+wxsz-8,y+8);
3646 3971 }
3647 13622 }
3648
4/8
✓ Branch 0 taken 11557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10823 times.
✓ Branch 3 taken 734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10823 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11557 else if((attack==wHammer) && ((attackclk==15) || ( spins>0 && attackclk >=15 )))
3649 {
3650 // poundable blocks
3651
2/2
✓ Branch 0 taken 129184 times.
✓ Branch 1 taken 734 times.
129918 for(int32_t q=0; q<176; q++)
3652 {
3653 129184 set_bit(screengrid,q,0);
3654 129184 set_bit(screengrid_layer[0],q,0);
3655 129184 set_bit(screengrid_layer[1],q,0);
3656 129184 }
3657
3658
2/2
✓ Branch 0 taken 11744 times.
✓ Branch 1 taken 734 times.
12478 for(dword q = MAXFFCS/8; q > 0; --q)
3659 11744 ffcgrid[q-1] = 0;
3660
3661
4/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 63 times.
734 if(dir==up && (x.getInt()&15)==0)
3662 {
3663 63 check_pound_block(wx,wy);
3664 63 check_pound_block(wx,wy+8);
3665 63 }
3666
3/10
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 618 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
671 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3667 {
3668 53 check_pound_block(wx,wy);
3669 53 check_pound_block(wx,wy+8);
3670 53 check_pound_block(wx+8,wy);
3671 53 check_pound_block(wx+8,wy+8);
3672 53 }
3673
3674
4/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 574 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 95 times.
734 if(dir==down && (x.getInt()&15)==0)
3675 {
3676 95 check_pound_block(wx,wy+wysz-8);
3677 95 check_pound_block(wx,wy+wysz);
3678 95 }
3679
5/10
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 574 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
639 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3680 {
3681 65 check_pound_block(wx,wy+wysz-8);
3682 65 check_pound_block(wx,wy+wysz);
3683 65 check_pound_block(wx+8,wy+wysz-8);
3684 65 check_pound_block(wx+8,wy+wysz);
3685 65 }
3686
3687
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 212 times.
734 if(dir==left)
3688 {
3689 212 check_pound_block(wx,y+8);
3690 212 check_pound_block(wx+8,y+8);
3691 212 }
3692
3693
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 246 times.
734 if(dir==right)
3694 {
3695 246 check_pound_block(wx+wxsz,y+8);
3696 246 check_pound_block(wx+wxsz-8,y+8);
3697 246 }
3698 734 }
3699 10823 else return false;
3700
3701 333298 return true;
3702 6418255 }
3703
3704 1703104 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3705 {
3706
2/2
✓ Branch 0 taken 1384 times.
✓ Branch 1 taken 1701720 times.
1703104 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
3707 {
3708 //zprint("bit off\n");
3709 1701720 return;
3710 }
3711 //keep things inside the screen boundaries
3712 1384 bx=vbound(bx, 0, 255);
3713 1384 by=vbound(by, 0, 176);
3714 1384 int32_t fx=vbound(bx, 0, 255);
3715 1384 int32_t fy=vbound(by, 0, 176);
3716 //first things first
3717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1384 times.
1384 if(attack!=wSword)
3718 return;
3719
3720
3/6
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1384 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 140 times.
1524 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3721
3/4
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 1244 times.
1384 || (attackclk>SWORDTAPFRAME && tapping))
3722 return;
3723
3724 //find out which combo row/column the coordinates are in
3725 1384 bx &= 0xF0;
3726 1384 by &= 0xF0;
3727
3728
3729 1384 int32_t flag = MAPFLAGL(layer,bx,by);
3730 1384 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3731 1384 int32_t cid = MAPCOMBOL(layer,bx,by);
3732 1384 int32_t type = combobuf[cid].type;
3733
1/2
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
1384 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3734 type = cNONE;
3735 //zprint("cid is: %d\n", cid);
3736 //zprint("type is: %d\n", type);
3737 1384 int32_t i = (bx>>4) + by;
3738
3739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1384 times.
1384 if(i > 175)
3740 return;
3741
3742 1384 bool ignorescreen=false;
3743
3744
2/4
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1384 times.
✗ Branch 3 not taken.
1384 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3745 1384 return;
3746
3747 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3748
3749 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3750 if(isCuttableNextType(type))
3751 {
3752 FFCore.tempScreens[layer]->data[i]++;
3753 }
3754 else
3755 {
3756 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3757 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3758 FFCore.tempScreens[layer]->sflag[i] = 0;
3759 }
3760 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3761 {
3762 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3763 sfx(tmpscr->secretsfx);
3764 }
3765 else if(isCuttableItemType(type))
3766 {
3767 int32_t it = -1;
3768 int32_t thedropset = -1;
3769
3770 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3771 if ( (combobuf[cid].usrflags&cflag2) )
3772 {
3773 if(combobuf[cid].usrflags&cflag11)
3774 it = combobuf[cid].attribytes[1];
3775 else
3776 {
3777 it = select_dropitem(combobuf[cid].attribytes[1]);
3778 thedropset = combobuf[cid].attribytes[1];
3779 }
3780 }
3781 else
3782 {
3783 it = select_dropitem(12);
3784 thedropset = 12;
3785 }
3786 if(it!=-1)
3787 {
3788 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3789 itm->from_dropset = thedropset;
3790 items.add(itm);
3791 }
3792 }
3793
3794 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3795
3796 if(get_bit(quest_rules,qr_MORESOUNDS))
3797 {
3798 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3799 {
3800 if (combobuf[cid].usrflags&cflag3)
3801 {
3802 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3803 }
3804 }
3805 else
3806 {
3807 if (combobuf[cid].usrflags&cflag3)
3808 {
3809 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3810 }
3811 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3812 }
3813 }
3814
3815 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
3816 if(decotype > 3) decotype = 0;
3817 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
3818 switch(decotype)
3819 {
3820 case -2: break; //nothing
3821 case -1:
3822 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
3823 break;
3824 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
3825 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
3826 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
3827 }
3828 1703104 }
3829
3830 779452 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3831 {
3832 //keep things inside the screen boundaries
3833 779452 bx=vbound(bx, 0, 255);
3834 779452 by=vbound(by, 0, 176);
3835 779452 int32_t fx=vbound(bx, 0, 255);
3836 779452 int32_t fy=vbound(by, 0, 176);
3837 //first things first
3838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779452 times.
779452 if(attack!=wSword)
3839 return;
3840
3841
4/6
✓ Branch 0 taken 779452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 779452 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 93790 times.
873494 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3842
4/4
✓ Branch 0 taken 775590 times.
✓ Branch 1 taken 3862 times.
✓ Branch 2 taken 94042 times.
✓ Branch 3 taken 681548 times.
779452 || (attackclk>SWORDTAPFRAME && tapping))
3843 4114 return;
3844
3845 //find out which combo row/column the coordinates are in
3846 775338 bx &= 0xF0;
3847 775338 by &= 0xF0;
3848
3849 775338 int cid = MAPCOMBO(bx,by);
3850 775338 int cid_ff = MAPFFCOMBO(fx,fy);
3851 775338 int current_ffcombo = getFFCAt(fx,fy);
3852 775338 newcombo const& cmb = combobuf[cid];
3853 775338 newcombo const& cmb_ff = combobuf[cid_ff];
3854 775338 int type = cmb.type;
3855 775338 int type2 = cmb_ff.type;
3856 775338 int flag = MAPFLAG(bx,by);
3857 775338 int flag2 = cmb.flag;
3858 775338 int flag3 = cmb_ff.flag;
3859 775338 int i = (bx>>4) + by;
3860
3861
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 775317 times.
775338 if(i > 175)
3862 21 return;
3863
3864 775317 bool ignorescreen=false;
3865 775317 bool ignoreffc=false;
3866
3867
2/2
✓ Branch 0 taken 8211 times.
✓ Branch 1 taken 767106 times.
775317 if(get_bit(screengrid, i) != 0)
3868 {
3869 8211 ignorescreen = true;
3870 8211 }
3871
2/2
✓ Branch 0 taken 767101 times.
✓ Branch 1 taken 5 times.
767106 else if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
3872 5 ignorescreen = true;
3873
3874
3875
3876
3/4
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 771608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3709 times.
775317 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
3877 {
3878 771608 ignoreffc = true;
3879 771608 }
3880
2/2
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 19 times.
3709 else if(cmb_ff.triggerflags[0] & combotriggerONLYGENTRIG)
3881 19 ignoreffc = true;
3882
3883
3/4
✓ Branch 0 taken 771658 times.
✓ Branch 1 taken 3659 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 771613 times.
1546930 if(!isCuttableType(type) &&
3884
6/6
✓ Branch 0 taken 1213 times.
✓ Branch 1 taken 770445 times.
✓ Branch 2 taken 771613 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 771568 times.
771658 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
3885 {
3886 771613 ignorescreen = true;
3887 771613 }
3888
3889
3/4
✓ Branch 0 taken 775298 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 775298 times.
1550615 if(!isCuttableType(type2) &&
3890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 775298 times.
775298 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
3891 {
3892 775298 ignoreffc = true;
3893 775298 }
3894
3895 775317 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
3896
3897
3/4
✓ Branch 0 taken 32952 times.
✓ Branch 1 taken 742365 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32952 times.
775317 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3898 775317 byte skipsecrets = 0;
3899
3900
2/2
✓ Branch 0 taken 772807 times.
✓ Branch 1 taken 2510 times.
775317 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
3901 {
3902
2/2
✓ Branch 0 taken 2466 times.
✓ Branch 1 taken 44 times.
2510 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
3903 {
3904 2466 skipsecrets = 0;
3905 2466 }
3906 44 else skipsecrets = 1; ;
3907 2510 }
3908
3909
6/6
✓ Branch 0 taken 2156 times.
✓ Branch 1 taken 773161 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 2117 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 51 times.
775317 if(!ignorescreen && (!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
3910 {
3911
5/6
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2103 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
2168 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
3912 {
3913 13 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3914 13 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3915 13 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3916 13 }
3917
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2151 times.
2155 else if(flag == mfARMOS_SECRET)
3918 {
3919 4 s->data[i] = s->secretcombo[sSTAIRS];
3920 4 s->cset[i] = s->secretcset[sSTAIRS];
3921 4 s->sflag[i] = s->secretflag[sSTAIRS];
3922 4 sfx(tmpscr->secretsfx);
3923 4 }
3924
4/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 2100 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 2094 times.
2151 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
3925 {
3926
4/4
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 45 times.
164 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3927 {
3928 107 findentrance(bx,by,mfSWORD+i2,true);
3929 107 }
3930
3931 45 findentrance(bx,by,mfSTRIKE,true);
3932 45 }
3933
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2094 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2094 else if(((flag2 >= 16)&&(flag2 <= 31)))
3934 {
3935 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3936 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3937 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3938 }
3939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2094 times.
2094 else if(flag2 == mfARMOS_SECRET)
3940 {
3941 s->data[i] = s->secretcombo[sSTAIRS];
3942 s->cset[i] = s->secretcset[sSTAIRS];
3943 s->sflag[i] = s->secretflag[sSTAIRS];
3944 sfx(tmpscr->secretsfx);
3945 }
3946
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2094 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2094 times.
2094 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
3947 {
3948 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3949 {
3950 findentrance(bx,by,mfSWORD+i2,true);
3951 }
3952
3953 findentrance(bx,by,mfSTRIKE,true);
3954 }
3955 else
3956 {
3957
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 1134 times.
2094 if(isCuttableNextType(type))
3958 {
3959 960 s->data[i]++;
3960 960 }
3961 else
3962 {
3963 1134 s->data[i] = s->undercombo;
3964 1134 s->cset[i] = s->undercset;
3965 1134 s->sflag[i] = 0;
3966 }
3967
3968 //pausenow=true;
3969 }
3970 2156 }
3971
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 773173 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
773173 else if(!ignorescreen && skipsecrets)
3972 {
3973 if(isCuttableNextType(type))
3974 {
3975 s->data[i]++;
3976 }
3977 else
3978 {
3979 s->data[i] = s->undercombo;
3980 s->cset[i] = s->undercset;
3981 s->sflag[i] = 0;
3982 }
3983 }
3984
3985
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 775329 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 775329 times.
775329 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
3986 {
3987 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3988 {
3989 findentrance(bx,by,mfSWORD+i2,true);
3990 }
3991
3992 findentrance(fx,fy,mfSTRIKE,true);
3993 }
3994
1/2
✓ Branch 0 taken 775329 times.
✗ Branch 1 not taken.
775329 else if(!ignoreffc)
3995 {
3996 if(isCuttableNextType(type2))
3997 {
3998 s->ffcs[current_ffcombo].incData(1);
3999 }
4000 else
4001 {
4002 s->ffcs[current_ffcombo].setData(s->undercombo);
4003 s->ffcs[current_ffcombo].cset = s->undercset;
4004 }
4005 }
4006
4007
2/2
✓ Branch 0 taken 773173 times.
✓ Branch 1 taken 2156 times.
775329 if(!ignorescreen)
4008 {
4009
4/4
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 1172 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 955 times.
2156 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
4010
4011
8/8
✓ Branch 0 taken 2133 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2134 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 21 times.
2156 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4012 {
4013
4/8
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
22 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4014 22 sfx(tmpscr->secretsfx);
4015 22 }
4016
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 2086 times.
2134 else if(isCuttableItemType(type))
4017 {
4018 2086 int32_t it = -1;
4019 2086 int32_t thedropset = -1;
4020
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2064 times.
2086 if ( (cmb.usrflags&cflag2) ) //specific dropset or item
4021 {
4022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if ( cmb.usrflags&cflag11 )
4023 {
4024 it = cmb.attribytes[1];
4025 }
4026 else
4027 {
4028 22 it = select_dropitem(cmb.attribytes[1]);
4029 22 thedropset = cmb.attribytes[1];
4030 }
4031 22 }
4032 else
4033 {
4034 2064 it = select_dropitem(12);
4035 2064 thedropset = 12;
4036 }
4037
4038
2/2
✓ Branch 0 taken 1459 times.
✓ Branch 1 taken 627 times.
2086 if(it!=-1)
4039 {
4040
4/8
✓ Branch 0 taken 627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 627 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 627 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 627 times.
✗ Branch 7 not taken.
627 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4041 627 itm->from_dropset = thedropset;
4042 627 items.add(itm);
4043 627 }
4044 2086 }
4045
4046 2156 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4047
4048
2/2
✓ Branch 0 taken 1963 times.
✓ Branch 1 taken 193 times.
2156 if(get_bit(quest_rules,qr_MORESOUNDS))
4049 {
4050
6/6
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 44 times.
193 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4051 {
4052
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 22 times.
44 if (cmb.usrflags&cflag3)
4053 {
4054 22 sfx(cmb.attribytes[2],int32_t(bx));
4055 22 }
4056 44 }
4057 else
4058 {
4059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (cmb.usrflags&cflag3)
4060 {
4061 sfx(cmb.attribytes[2],int32_t(bx));
4062 }
4063 149 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4064 }
4065 193 }
4066
4067
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2036 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
2156 int16_t decotype = (cmb.usrflags & cflag1) ? ((cmb.usrflags & cflag10) ? (cmb.attribytes[0]) : (-1)) : (0);
4068
1/2
✓ Branch 0 taken 2156 times.
✗ Branch 1 not taken.
2156 if(decotype > 3) decotype = 0;
4069
7/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2036 times.
✓ Branch 2 taken 350 times.
✓ Branch 3 taken 1686 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1686 times.
✓ Branch 6 taken 553 times.
✓ Branch 7 taken 1133 times.
2156 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((cmb.usrflags & cflag1) ? -1 : -2))));
4070
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 449 times.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 553 times.
2156 switch(decotype)
4071 {
4072 1133 case -2: break; //nothing
4073 case -1:
4074 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, cmb.attribytes[0]));
4075 break;
4076
3/6
✓ Branch 0 taken 449 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 449 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 449 times.
✗ Branch 5 not taken.
449 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4077
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4078
3/6
✓ Branch 0 taken 553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 553 times.
✗ Branch 5 not taken.
553 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4079 }
4080 2156 }
4081
4082
1/2
✓ Branch 0 taken 775329 times.
✗ Branch 1 not taken.
775329 if(!ignoreffc)
4083 {
4084 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4085
4086 if(isCuttableItemType(type2))
4087 {
4088 int32_t it=-1;
4089 int32_t thedropset=-1;
4090 if ( (cmb_ff.usrflags&cflag2) )
4091 {
4092 if(cmb_ff.usrflags&cflag11)
4093 it = cmb_ff.attribytes[1];
4094 else
4095 {
4096 it = select_dropitem(cmb_ff.attribytes[1]);
4097 thedropset = cmb_ff.attribytes[1];
4098 }
4099 }
4100 else
4101 {
4102 if(get_bit(quest_rules,qr_HARDCODED_FFC_BUSH_DROPS))
4103 {
4104 int32_t r=zc_oldrand()%100;
4105
4106 if(r<15)
4107 it=iHeart; // 15%
4108 else if(r<35)
4109 it=iRupy; // 20%
4110 }
4111 else
4112 {
4113 it = select_dropitem(12);
4114 thedropset = 12;
4115 }
4116 }
4117
4118 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4119 {
4120 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4121 itm->from_dropset = thedropset;
4122 items.add(itm);
4123 }
4124 }
4125
4126 if(get_bit(quest_rules,qr_MORESOUNDS))
4127 {
4128 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4129 {
4130 if (cmb_ff.usrflags&cflag3)
4131 {
4132 sfx(cmb_ff.attribytes[2],int32_t(bx));
4133 }
4134 }
4135 else
4136 {
4137 if (cmb_ff.usrflags&cflag3)
4138 {
4139 sfx(cmb_ff.attribytes[2],int32_t(bx));
4140 }
4141 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4142 }
4143 }
4144
4145 int16_t decotype = (cmb_ff.usrflags & cflag1) ? ((cmb_ff.usrflags & cflag10) ? (cmb_ff.attribytes[0]) : (-1)) : (0);
4146 if(decotype > 3) decotype = 0;
4147 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((cmb_ff.usrflags & cflag1) ? -1 : -2))));
4148 switch(decotype)
4149 {
4150 case -2: break; //nothing
4151 case -1:
4152 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, cmb_ff.attribytes[0]));
4153 break;
4154 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4155 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4156 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4157 }
4158 }
4159 779464 }
4160
4161 13019260 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4162 {
4163 /*
4164 int32_t par_item = w->parentitem;
4165 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4166 int32_t usewpn = -1;
4167 if ( par_item > -1 )
4168 {
4169 usewpn = itemsbuf[par_item].useweapon;
4170 }
4171 else if ( par_item == -1 && w->ScriptGenerated )
4172 {
4173 usewpn = w->useweapon;
4174 }
4175 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4176
4177 */
4178 13019260 bx=vbound(bx, 0, 255);
4179 13019260 by=vbound(by, 0, 176);
4180 13019260 int32_t cid = MAPCOMBO(bx,by);
4181
3/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 201168 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 12816844 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1248 times.
✗ Branch 29 not taken.
13019260 switch(w->useweapon)
4182 {
4183 case wArrow:
4184 findentrance(bx,by,mfARROW,true);
4185 findentrance(bx,by,mfSARROW,true);
4186 findentrance(bx,by,mfGARROW,true);
4187 break;
4188 case wBeam:
4189 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4190 break;
4191 case wHookshot:
4192 findentrance(bx,by,mfHOOKSHOT,true);
4193 break;
4194 case wBrang:
4195 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4196 break;
4197 case wMagic:
4198 findentrance(bx,by,mfWANDMAGIC,true);
4199 break;
4200 case wRefMagic:
4201 findentrance(bx,by,mfWANDMAGIC,true);
4202 break;
4203 case wRefBeam:
4204 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4205 break;
4206 //reflected magic needs to happen in mirrors:
4207 //
4208 //findentrance(bx,by,mfREFMAGIC,true)
4209 case wRefFireball:
4210 findentrance(bx,by,mfREFFIREBALL,true);
4211 break;
4212 case wBomb:
4213 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4214 break;
4215
4216 case wSBomb:
4217 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4218 break;
4219
4220 case wFire:
4221 201168 findentrance(bx,by,mfANYFIRE,true);
4222 201168 findentrance(bx,by,mfSTRONGFIRE,true);
4223 201168 findentrance(bx,by,mfMAGICFIRE,true);
4224 /* if we want the weapon to die
4225 if (findentrance(bx,by,mfANYFIRE,true) ) dead = 1;
4226 if (findentrance(bx,by,mfSTRONGFIRE,true) ) dead = 1;
4227 if (findentrance(bx,by,mfMAGICFIRE,true)) dead = 1;
4228 */
4229 201168 break;
4230
4231 case wScript1:
4232 break;
4233 case wScript2:
4234 break;
4235 case wScript3:
4236 break;
4237 case wScript4:
4238 break;
4239 case wScript5:
4240 break;
4241 case wScript6:
4242 break;
4243 case wScript7:
4244 break;
4245 case wScript8:
4246 break;
4247 case wScript9:
4248 break;
4249 case wScript10:
4250 break;
4251 case wIce:
4252 break;
4253 case wCByrna:
4254 break;
4255 case wWhistle:
4256 break;
4257 case wSSparkle:
4258 case wFSparkle:
4259 break;
4260 case wWind:
4261 break;
4262 case wBait:
4263 break;
4264 case wFlame:
4265 case wThrown:
4266 case wBombos:
4267 case wEther:
4268 case wQuake:
4269 case wSwordLA:
4270 case wSword180:
4271 case wStomp:
4272 break;
4273 case wSword:
4274 case wWand:
4275 //case wCandle:
4276 case wHSHandle:
4277 case wLitBomb:
4278 case wLitSBomb:
4279 1248 break;
4280 12816844 default: break;
4281
4282 }
4283 13019260 }
4284
4285 26038520 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4286 {
4287
4288
2/2
✓ Branch 0 taken 95758 times.
✓ Branch 1 taken 25942762 times.
26038520 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
4289 {
4290 //zprint("bit off\n");
4291 25942762 return;
4292 }
4293 //keep things inside the screen boundaries
4294 95758 bx=vbound(bx, 0, 255);
4295 95758 by=vbound(by, 0, 176);
4296 95758 int32_t fx=vbound(bx, 0, 255);
4297 95758 int32_t fy=vbound(by, 0, 176);
4298 //first things first
4299
1/2
✓ Branch 0 taken 95758 times.
✗ Branch 1 not taken.
95758 if(w->useweapon != wSword)
4300 95758 return;
4301
4302 //find out which combo row/column the coordinates are in
4303 bx &= 0xF0;
4304 by &= 0xF0;
4305
4306
4307 int32_t flag = MAPFLAGL(layer,bx,by);
4308 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4309 int32_t cid = MAPCOMBOL(layer,bx,by);
4310 int32_t type = combobuf[cid].type;
4311 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4312 type = cNONE;
4313 //zprint("cid is: %d\n", cid);
4314 //zprint("type is: %d\n", type);
4315 int32_t i = (bx>>4) + by;
4316
4317 if(i > 175)
4318 return;
4319
4320 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4321 {
4322 return;
4323 //ignorescreen = true;
4324 //zprint("ignoring\n");
4325 }
4326
4327 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4328
4329 {
4330 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4331 if(isCuttableNextType(type) || isCuttableNextType(type))
4332 {
4333 FFCore.tempScreens[layer]->data[i]++;
4334 }
4335 else
4336 {
4337 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4338 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4339 FFCore.tempScreens[layer]->sflag[i] = 0;
4340 }
4341 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4342 {
4343 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4344 sfx(tmpscr->secretsfx);
4345 }
4346 else if(isCuttableItemType(type))
4347 {
4348 int32_t it = -1;
4349 int32_t thedropset = -1;
4350
4351 if ( (combobuf[cid].usrflags&cflag2) )
4352 {
4353 if(combobuf[cid].usrflags&cflag11)
4354 it = combobuf[cid].attribytes[1];
4355 else
4356 {
4357 it = select_dropitem(combobuf[cid].attribytes[1]);
4358 thedropset = combobuf[cid].attribytes[1];
4359 }
4360 }
4361 else
4362 {
4363 it = select_dropitem(12);
4364 thedropset = 12;
4365 }
4366
4367 if(it!=-1)
4368 {
4369 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4370 itm->from_dropset = thedropset;
4371 items.add(itm);
4372 }
4373 }
4374
4375 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4376
4377 if(get_bit(quest_rules,qr_MORESOUNDS))
4378 {
4379 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4380 {
4381 if (combobuf[cid].usrflags&cflag3)
4382 {
4383 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4384 }
4385 }
4386 else
4387 {
4388 if (combobuf[cid].usrflags&cflag3)
4389 {
4390 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4391 }
4392 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4393 }
4394 }
4395
4396 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4397 if(decotype > 3) decotype = 0;
4398 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4399 switch(decotype)
4400 {
4401 case -2: break; //nothing
4402 case -1:
4403 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4404 break;
4405 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4406 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4407 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4408 }
4409
4410 }
4411
4412 26038520 }
4413
4414 13019260 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4415 {
4416 /*
4417 int32_t par_item = w->parentitem;
4418 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4419 int32_t usewpn = -1;
4420 if ( par_item > -1 )
4421 {
4422 usewpn = itemsbuf[par_item].useweapon;
4423 }
4424 else if ( par_item == -1 && w->ScriptGenerated )
4425 {
4426 usewpn = w->useweapon;
4427 }
4428 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4429 */
4430
4431
4432 //keep things inside the screen boundaries
4433 13019260 bx=vbound(bx, 0, 255);
4434 13019260 by=vbound(by, 0, 176);
4435 13019260 int32_t fx=vbound(bx, 0, 255);
4436 13019260 int32_t fy=vbound(by, 0, 176);
4437 13019260 int32_t cid = MAPCOMBO(bx,by);
4438
4439 //find out which combo row/column the coordinates are in
4440 13019260 bx &= 0xF0;
4441 13019260 by &= 0xF0;
4442
4443 13019260 int32_t type = COMBOTYPE(bx,by);
4444 13019260 int32_t type2 = FFCOMBOTYPE(fx,fy);
4445 13019260 int32_t flag = MAPFLAG(bx,by);
4446 13019260 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4447 13019260 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4448
2/2
✓ Branch 0 taken 13019046 times.
✓ Branch 1 taken 214 times.
13019260 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4449 214 type = cNONE;
4450 13019260 byte dontignore = 0;
4451 13019260 byte dontignoreffc = 0;
4452
4453
4/4
✓ Branch 0 taken 217832 times.
✓ Branch 1 taken 12801428 times.
✓ Branch 2 taken 217533 times.
✓ Branch 3 taken 299 times.
13019260 if (isCuttableType(type) && MatchComboTrigger(w, combobuf, cid))
4454 {
4455 299 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4456 299 dontignore = 1;
4457 299 }
4458
4459 /*to-do, ffcs
4460 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4461 {
4462 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4463 dontignoreffc = 1;
4464 }*/
4465
4/4
✓ Branch 0 taken 13018012 times.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 13017713 times.
✓ Branch 3 taken 299 times.
13019260 if(w->useweapon != wSword && !dontignore) return;
4466
4467
4468 1547 int32_t i = (bx>>4) + by;
4469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4470
4471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if(i > 175)
4472 return;
4473
4474 1547 bool ignorescreen=false;
4475 1547 bool ignoreffc=false;
4476
4477
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(get_bit(w->wscreengrid, i) != 0)
4478 {
4479 ignorescreen = true; dontignore = 0;
4480 }
4481
4482 1547 int32_t current_ffcombo = getFFCAt(fx,fy);
4483
4484
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1545 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
1547 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4485 {
4486 1545 ignoreffc = true;
4487 1545 }
4488
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4489 type2 = cNONE;
4490
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
2795 if(!isCuttableType(type) &&
4491
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 1248 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1248 times.
1248 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4492 {
4493 1248 ignorescreen = true;
4494 1248 }
4495
4496
2/4
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
3094 if(!isCuttableType(type2) &&
4497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4498 {
4499 1547 ignoreffc = true;
4500 1547 }
4501
4502 1547 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4503
4504
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1248 times.
1547 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4505 1547 byte skipsecrets = 0;
4506
2/2
✓ Branch 0 taken 1298 times.
✓ Branch 1 taken 249 times.
1547 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4507 {
4508
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
4509 {
4510 249 skipsecrets = 0;
4511 249 }
4512 else skipsecrets = 1;
4513 249 }
4514
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 1248 times.
✓ Branch 4 taken 1248 times.
✓ Branch 5 taken 1547 times.
1547 if((!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4515 {
4516
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2795 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4517 {
4518 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4519 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4520 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4521 }
4522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag == mfARMOS_SECRET)
4523 {
4524 s->data[i] = s->secretcombo[sSTAIRS];
4525 s->cset[i] = s->secretcset[sSTAIRS];
4526 s->sflag[i] = s->secretflag[sSTAIRS];
4527 sfx(tmpscr->secretsfx);
4528 }
4529
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4530 {
4531 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4532 {
4533 findentrance(bx,by,mfSWORD+i2,true);
4534 }
4535
4536 findentrance(bx,by,mfSTRIKE,true);
4537 }
4538
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
299 else if(((flag2 >= 16)&&(flag2 <= 31)))
4539 {
4540 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4541 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4542 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4543 }
4544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag2 == mfARMOS_SECRET)
4545 {
4546 s->data[i] = s->secretcombo[sSTAIRS];
4547 s->cset[i] = s->secretcset[sSTAIRS];
4548 s->sflag[i] = s->secretflag[sSTAIRS];
4549 sfx(tmpscr->secretsfx);
4550 }
4551
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4552 {
4553 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4554 {
4555 findentrance(bx,by,mfSWORD+i2,true);
4556 }
4557
4558 findentrance(bx,by,mfSTRIKE,true);
4559 }
4560 else
4561 {
4562
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 50 times.
299 if(isCuttableNextType(type))
4563 {
4564 249 s->data[i]++;
4565 249 }
4566 else
4567 {
4568 50 s->data[i] = s->undercombo;
4569 50 s->cset[i] = s->undercset;
4570 50 s->sflag[i] = 0;
4571 }
4572
4573 //pausenow=true;
4574 }
4575 299 }
4576
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1248 else if(skipsecrets && (!ignorescreen || dontignore))
4577 {
4578 if(isCuttableNextType(type))
4579 {
4580 s->data[i]++;
4581 }
4582 else
4583 {
4584 s->data[i] = s->undercombo;
4585 s->cset[i] = s->undercset;
4586 s->sflag[i] = 0;
4587 }
4588 }
4589
4590
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
1547 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4591 {
4592 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4593 {
4594 findentrance(bx,by,mfSWORD+i2,true);
4595 }
4596
4597 findentrance(fx,fy,mfSTRIKE,true);
4598 }
4599
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 else if(!ignoreffc)
4600 {
4601 if(isCuttableNextType(type2))
4602 {
4603 s->ffcs[current_ffcombo].incData(1);
4604 }
4605 else
4606 {
4607 s->ffcs[current_ffcombo].setData(s->undercombo);
4608 s->ffcs[current_ffcombo].cset = s->undercset;
4609 }
4610 }
4611
4612
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
1547 if(!ignorescreen || dontignore)
4613 {
4614
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
299 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4615
4616
2/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4617 {
4618 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4619 sfx(tmpscr->secretsfx);
4620 }
4621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(isCuttableItemType(type))
4622 {
4623 299 int32_t it = -1;
4624 299 int32_t thedropset = -1;
4625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4626 {
4627 if ( combobuf[cid].usrflags&cflag11 )
4628 {
4629 it = combobuf[cid].attribytes[1];
4630 }
4631 else
4632 {
4633 it = select_dropitem(combobuf[cid].attribytes[1]);
4634 thedropset = combobuf[cid].attribytes[1];
4635 }
4636 }
4637 else
4638 {
4639 299 it = select_dropitem(12);
4640 299 thedropset = 12;
4641 }
4642
4643
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 99 times.
299 if(it!=-1)
4644 {
4645
4/8
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 99 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 99 times.
✗ Branch 7 not taken.
99 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4646 99 itm->from_dropset = thedropset;
4647 99 items.add(itm);
4648 99 }
4649 299 }
4650
4651
4652 299 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4653
4654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if(get_bit(quest_rules,qr_MORESOUNDS))
4655 {
4656
5/6
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 161 times.
✗ Branch 5 not taken.
299 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4657 {
4658 if (combobuf[cid].usrflags&cflag3)
4659 {
4660 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4661 }
4662 }
4663 else
4664 {
4665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if (combobuf[cid].usrflags&cflag3)
4666 {
4667 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4668 }
4669 299 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4670 }
4671 299 }
4672
4673
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
299 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4674
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(decotype > 3) decotype = 0;
4675
1/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4676
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
299 switch(decotype)
4677 {
4678 case -2: break; //nothing
4679 case -1:
4680 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4681 break;
4682
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
249 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4683
3/6
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
50 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4684 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4685 }
4686 299 }
4687
4688
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(!ignoreffc)
4689 {
4690 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4691
4692 if(isCuttableItemType(type2))
4693 {
4694 int32_t it=-1;
4695 int32_t thedropset=-1;
4696 if ( (combobuf[cid].usrflags&cflag2) )
4697 {
4698 if(combobuf[cid].usrflags&cflag11)
4699 it = combobuf[cid].attribytes[1];
4700 else
4701 {
4702 it = select_dropitem(combobuf[cid].attribytes[1]);
4703 thedropset = combobuf[cid].attribytes[1];
4704 }
4705 }
4706 else
4707 {
4708 int32_t r=zc_oldrand()%100;
4709
4710 if(r<15)
4711 {
4712 it=iHeart; // 15%
4713 }
4714 else if(r<35)
4715 {
4716 it=iRupy; // 20%
4717 }
4718 }
4719
4720 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4721 {
4722 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4723 itm->from_dropset = thedropset;
4724 items.add(itm);
4725 }
4726 }
4727
4728 if(get_bit(quest_rules,qr_MORESOUNDS))
4729 {
4730 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4731 {
4732 if (combobuf[cid].usrflags&cflag3)
4733 {
4734 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4735 }
4736 }
4737 else
4738 {
4739 if (combobuf[cid].usrflags&cflag3)
4740 {
4741 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4742 }
4743 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4744 }
4745 }
4746
4747 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4748 if(decotype > 3) decotype = 0;
4749 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4750 switch(decotype)
4751 {
4752 case -2: break; //nothing
4753 case -1:
4754 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4755 break;
4756 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4757 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4758 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4759 }
4760 }
4761 13019260 }
4762
4763 13019260 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4764 {
4765 /*
4766 int32_t par_item = w->parentitem;
4767 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4768 int32_t usewpn = -1;
4769 if ( par_item > -1 )
4770 {
4771 usewpn = itemsbuf[par_item].useweapon;
4772 }
4773 else if ( par_item == -1 && w->ScriptGenerated )
4774 {
4775 usewpn = w->useweapon;
4776 }
4777 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4778 */
4779
4780 13019260 byte dontignore = 0;
4781 13019260 byte dontignoreffc = 0;
4782
4783
4784
4785
4786
4787 //keep things inside the screen boundaries
4788 13019260 bx=vbound(bx, 0, 255);
4789 13019260 by=vbound(by, 0, 176);
4790 13019260 int32_t fx=vbound(bx, 0, 255);
4791 13019260 int32_t fy=vbound(by, 0, 176);
4792 13019260 int32_t cid = MAPCOMBO(bx,by);
4793
4794 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4795
3/4
✓ Branch 0 taken 13019260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✓ Branch 3 taken 13018601 times.
13019260 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf, cid)) return;
4796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 659 times.
659 if ( MatchComboTrigger (w, combobuf, cid) ) dontignore = 1;
4797
4798 //first things first
4799
2/4
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 659 times.
659 if(z>8||fakez>8) return;
4800
4801 //find out which combo row/column the coordinates are in
4802 659 bx &= 0xF0;
4803 659 by &= 0xF0;
4804
4805 659 int32_t flag = MAPFLAG(bx,by);
4806 659 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4807 659 int32_t flag3=0;
4808 659 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4809 659 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4810 659 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4811 659 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4812
4813
4/8
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 659 times.
659 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4814 flag3=mfWAND;
4815
4816
4/8
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 659 times.
659 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4817 flag3=mfSTRIKE;
4818
4819 659 int32_t i = (bx>>4) + by;
4820
4821
6/12
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 659 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 659 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 659 times.
659 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4822 659 return;
4823
4824 if(i > 175)
4825 return;
4826
4827 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4828
4829 //findentrance(bx,by,mfWAND,true);
4830 //findentrance(bx,by,mfSTRIKE,true);
4831 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4832 {
4833 if(flag3==mfWAND||flag3==mfSTRIKE)
4834 {
4835 findentrance(fx,fy,mfWAND,true);
4836 findentrance(fx,fy,mfSTRIKE,true);
4837 }
4838 }
4839
4840 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4841
4842 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4843 13019260 }
4844
4845 void HeroClass::check_slash_block(weapon *w)
4846 {
4847 //first things
4848
4849 int32_t par_item = w->parentitem;
4850 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4851 int32_t usewpn = -1;
4852 if ( par_item > -1 )
4853 {
4854 usewpn = itemsbuf[par_item].useweapon;
4855 }
4856 else if ( par_item == -1 && w->ScriptGenerated )
4857 {
4858 usewpn = w->useweapon;
4859 }
4860 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4861 if(usewpn != wSword) return;
4862
4863
4864 int32_t bx = 0, by = 0;
4865 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
4866 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
4867 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
4868 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
4869 //keep things inside the screen boundaries
4870 bx=vbound(bx, 0, 255);
4871 by=vbound(by, 0, 176);
4872 int32_t fx=vbound(bx, 0, 255);
4873 int32_t fy=vbound(by, 0, 176);
4874
4875 int32_t cid = MAPCOMBO(bx,by);
4876
4877 //find out which combo row/column the coordinates are in
4878 bx &= 0xF0;
4879 by &= 0xF0;
4880
4881 int32_t type = COMBOTYPE(bx,by);
4882 int32_t type2 = FFCOMBOTYPE(fx,fy);
4883 int32_t flag = MAPFLAG(bx,by);
4884 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4885 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4886 int32_t i = (bx>>4) + by;
4887
4888 if(i > 175)
4889 {
4890 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
4891 return;
4892 }
4893
4894 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4895 type = cNONE;
4896 bool ignorescreen=false;
4897 bool ignoreffc=false;
4898
4899 if(get_bit(screengrid, i) != 0)
4900 {
4901 ignorescreen = true;
4902 }
4903
4904 int32_t current_ffcombo = getFFCAt(fx,fy);
4905
4906 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4907 {
4908 ignoreffc = true;
4909 }
4910 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4911 type2 = cNONE;
4912 if(!isCuttableType(type) &&
4913 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4914 {
4915 ignorescreen = true;
4916 }
4917
4918 if(!isCuttableType(type2) &&
4919 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4920 {
4921 ignoreffc = true;
4922 }
4923
4924 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4925
4926 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
4927
4928 if(!ignorescreen)
4929 {
4930 if((flag >= 16)&&(flag <= 31))
4931 {
4932 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4933 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4934 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4935 }
4936 else if(flag == mfARMOS_SECRET)
4937 {
4938 s->data[i] = s->secretcombo[sSTAIRS];
4939 s->cset[i] = s->secretcset[sSTAIRS];
4940 s->sflag[i] = s->secretflag[sSTAIRS];
4941 sfx(tmpscr->secretsfx);
4942 }
4943 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4944 {
4945 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4946 {
4947 findentrance(bx,by,mfSWORD+i2,true);
4948 }
4949
4950 findentrance(bx,by,mfSTRIKE,true);
4951 }
4952 else if(((flag2 >= 16)&&(flag2 <= 31)))
4953 {
4954 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4955 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4956 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4957 }
4958 else if(flag2 == mfARMOS_SECRET)
4959 {
4960 s->data[i] = s->secretcombo[sSTAIRS];
4961 s->cset[i] = s->secretcset[sSTAIRS];
4962 s->sflag[i] = s->secretflag[sSTAIRS];
4963 sfx(tmpscr->secretsfx);
4964 }
4965 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4966 {
4967 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4968 {
4969 findentrance(bx,by,mfSWORD+i2,true);
4970 }
4971
4972 findentrance(bx,by,mfSTRIKE,true);
4973 }
4974 else
4975 {
4976 if(isCuttableNextType(type))
4977 {
4978 s->data[i]++;
4979 }
4980 else
4981 {
4982 s->data[i] = s->undercombo;
4983 s->cset[i] = s->undercset;
4984 s->sflag[i] = 0;
4985 }
4986
4987 //pausenow=true;
4988 }
4989 }
4990
4991 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4992 {
4993 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4994 {
4995 findentrance(bx,by,mfSWORD+i2,true);
4996 }
4997
4998 findentrance(fx,fy,mfSTRIKE,true);
4999 }
5000 else if(!ignoreffc)
5001 {
5002 if(isCuttableNextType(type2))
5003 {
5004 s->ffcs[current_ffcombo].incData(1);
5005 }
5006 else
5007 {
5008 s->ffcs[current_ffcombo].setData(s->undercombo);
5009 s->ffcs[current_ffcombo].cset = s->undercset;
5010 }
5011 }
5012
5013 if(!ignorescreen)
5014 {
5015 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5016
5017 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5018 {
5019 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5020 sfx(tmpscr->secretsfx);
5021 }
5022 else if(isCuttableItemType(type))
5023 {
5024 int32_t it = -1;
5025 int32_t thedropset = -1;
5026 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5027 {
5028 if ( combobuf[cid].usrflags&cflag11 )
5029 {
5030 it = combobuf[cid].attribytes[1];
5031 }
5032 else
5033 {
5034 it = select_dropitem(combobuf[cid].attribytes[1]);
5035 thedropset = combobuf[cid].attribytes[1];
5036 }
5037 }
5038 else
5039 {
5040 it = select_dropitem(12);
5041 thedropset = 12;
5042 }
5043
5044 if(it!=-1)
5045 {
5046 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5047 itm->from_dropset = thedropset;
5048 items.add(itm);
5049 }
5050 }
5051
5052 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5053
5054 if(get_bit(quest_rules,qr_MORESOUNDS))
5055 {
5056 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5057 {
5058 if (combobuf[cid].usrflags&cflag3)
5059 {
5060 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5061 }
5062 }
5063 else
5064 {
5065 if (combobuf[cid].usrflags&cflag3)
5066 {
5067 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5068 }
5069 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5070 }
5071 }
5072
5073 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5074 if(decotype > 3) decotype = 0;
5075 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5076 switch(decotype)
5077 {
5078 case -2: break; //nothing
5079 case -1:
5080 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5081 break;
5082 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5083 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5084 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5085 }
5086 }
5087
5088 if(!ignoreffc)
5089 {
5090 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5091
5092 if(isCuttableItemType(type2))
5093 {
5094 int32_t it=-1;
5095 int32_t thedropset = -1;
5096 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5097 {
5098 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5099 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5100 else
5101 {
5102 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5103 it = select_dropitem(thedropset);
5104 }
5105 }
5106 else
5107 {
5108 it = select_dropitem(12);
5109 thedropset = 12;
5110 }
5111
5112 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5113 {
5114 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5115 itm->from_dropset = thedropset;
5116 items.add(itm);
5117 }
5118 }
5119
5120 if(get_bit(quest_rules,qr_MORESOUNDS))
5121 {
5122 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5123 {
5124 if (combobuf[cid].usrflags&cflag3)
5125 {
5126 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5127 }
5128 }
5129 else
5130 {
5131 if (combobuf[cid].usrflags&cflag3)
5132 {
5133 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5134 }
5135 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5136 }
5137 }
5138
5139 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5140 if(decotype > 3) decotype = 0;
5141 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5142 switch(decotype)
5143 {
5144 case -2: break; //nothing
5145 case -1:
5146 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5147 break;
5148 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5149 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5150 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5151 }
5152 }
5153 }
5154
5155 //TODO: Boomerang that cuts bushes. -L
5156 /*void HeroClass::slash_bush()
5157 {
5158
5159 }*/
5160
5161 31820 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5162 {
5163 //keep things inside the screen boundaries
5164 31820 bx=vbound(bx, 0, 255);
5165 31820 by=vbound(by, 0, 176);
5166 31820 int32_t fx=vbound(bx, 0, 255);
5167 31820 int32_t fy=vbound(by, 0, 176);
5168 31820 int32_t cid = MAPCOMBO(bx,by);
5169
5170 //first things first
5171
2/4
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31820 times.
31820 if(z>8||fakez>8) return;
5172
5173 //find out which combo row/column the coordinates are in
5174 31820 bx &= 0xF0;
5175 31820 by &= 0xF0;
5176
5177 31820 int32_t flag = MAPFLAG(bx,by);
5178 31820 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5179 31820 int32_t flag3=0;
5180 31820 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5181 31820 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5182 31820 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5183 31820 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5184
5185
4/8
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31820 times.
31820 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5186 flag3=mfWAND;
5187
5188
4/8
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31820 times.
31820 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5189 flag3=mfSTRIKE;
5190
5191 31820 int32_t i = (bx>>4) + by;
5192
5193
6/12
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31820 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 31820 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 31820 times.
✗ Branch 11 not taken.
31820 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5194 31820 return;
5195
5196 if(i > 175)
5197 return;
5198
5199 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5200
5201 //findentrance(bx,by,mfWAND,true);
5202 //findentrance(bx,by,mfSTRIKE,true);
5203 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5204 {
5205 if(flag3==mfWAND||flag3==mfSTRIKE)
5206 {
5207 findentrance(fx,fy,mfWAND,true);
5208 findentrance(fx,fy,mfSTRIKE,true);
5209 }
5210 }
5211
5212 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5213 31820 }
5214
5215 1704 void HeroClass::check_pound_block(int bx, int by, weapon* w)
5216 {
5217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1704 if(w && w->no_triggers()) return;
5218
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1704 if(w && w->id == wHammer && getHammerState() < 3)
5219 return;
5220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 if(get_bit(quest_rules,qr_POUNDLAYERS1AND2))
5221 {
5222 check_pound_block_layer(bx,by,1,w);
5223 check_pound_block_layer(bx,by,2,w);
5224 }
5225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 auto* grid = w ? w->wscreengrid : screengrid;
5226 //keep things inside the screen boundaries
5227 1704 bx=vbound(bx, 0, 255);
5228 1704 by=vbound(by, 0, 176);
5229 1704 int32_t fx=vbound(bx, 0, 255);
5230 1704 int32_t fy=vbound(by, 0, 176);
5231 1704 int32_t cid = MAPCOMBO(bx,by);
5232
5233 //first things first
5234
2/4
✓ Branch 0 taken 1704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1704 times.
1704 if(z>8||fakez>8) return;
5235
5236 //find out which combo row/column the coordinates are in
5237 1704 bx &= 0xF0;
5238 1704 by &= 0xF0;
5239
5240 1704 int32_t type = COMBOTYPE(bx,by);
5241 1704 int32_t type2 = FFCOMBOTYPE(fx,fy);
5242 1704 int32_t flag = MAPFLAG(bx,by);
5243 1704 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5244 1704 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5245 1704 int32_t i = (bx>>4) + by;
5246
5247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 if(i > 175)
5248 return;
5249
5250 1704 bool ignorescreen=false;
5251 1704 bool ignoreffc=false;
5252 1704 bool pound=false;
5253
5254
6/10
✓ Branch 0 taken 1646 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 1646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1646 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1646 times.
1704 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5255 1646 ignorescreen = true; // Affect only FFCs
5256
5257
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 27 times.
1704 if(get_bit(grid, i) != 0)
5258 27 ignorescreen = true;
5259
5260 1704 int32_t current_ffcombo = getFFCAt(fx,fy);
5261
5262
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1703 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1704 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5263 1703 ignoreffc = true;
5264
5265
3/6
✓ Branch 0 taken 1704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1704 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1704 times.
1704 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5266 1704 ignoreffc = true;
5267
5268
3/4
✓ Branch 0 taken 1654 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
1704 if(ignorescreen && ignoreffc) // Nothing to do.
5269 1654 return;
5270
5271 50 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5272
5273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(!ignorescreen)
5274 {
5275
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
50 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5276 {
5277 findentrance(bx,by,mfHAMMER,true);
5278 findentrance(bx,by,mfSTRIKE,true);
5279 }
5280
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
50 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5281 {
5282 findentrance(bx,by,mfHAMMER,true);
5283 findentrance(bx,by,mfSTRIKE,true);
5284 }
5285
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 else if((flag >= 16)&&(flag <= 31))
5286 {
5287 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5288 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5289 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5290 }
5291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 else if(flag == mfARMOS_SECRET)
5292 {
5293 s->data[i] = s->secretcombo[sSTAIRS];
5294 s->cset[i] = s->secretcset[sSTAIRS];
5295 s->sflag[i] = s->secretflag[sSTAIRS];
5296 sfx(tmpscr->secretsfx);
5297 }
5298
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 else if((flag2 >= 16)&&(flag2 <= 31))
5299 {
5300 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5301 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5302 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5303 }
5304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 else if(flag2 == mfARMOS_SECRET)
5305 {
5306 s->data[i] = s->secretcombo[sSTAIRS];
5307 s->cset[i] = s->secretcset[sSTAIRS];
5308 s->sflag[i] = s->secretflag[sSTAIRS];
5309 sfx(tmpscr->secretsfx);
5310 }
5311 50 else pound = true;
5312 50 }
5313
5314
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(!ignoreffc)
5315 {
5316 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5317 {
5318 findentrance(fx,fy,mfHAMMER,true);
5319 findentrance(fx,fy,mfSTRIKE,true);
5320 }
5321 else
5322 {
5323 s->ffcs[current_ffcombo].incData(1);
5324 }
5325 }
5326
5327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(!ignorescreen)
5328 {
5329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(pound)
5330 50 s->data[i]+=1;
5331
5332 50 set_bit(grid,i,1);
5333
5334
2/8
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
50 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5335 {
5336 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5337 sfx(tmpscr->secretsfx);
5338 }
5339
5340
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
50 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5341 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5342
5343 50 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5344 50 }
5345
5346
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(!ignoreffc)
5347 {
5348 set_bit(ffcgrid,current_ffcombo,1);
5349
5350 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5351 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5352 }
5353
5354 50 return;
5355 1704 }
5356
5357 void HeroClass::check_pound_block_layer(int bx, int by, int lyr, weapon* w)
5358 {
5359 if(lyr < 1 || lyr > 2) return; //sanity
5360 //keep things inside the screen boundaries
5361 bx=vbound(bx, 0, 255);
5362 by=vbound(by, 0, 176);
5363 int32_t cid = MAPCOMBOL(lyr,bx,by);
5364 newcombo const& scr_cmb = combobuf[cid];
5365 auto* grid = w ? w->wscreengrid_layer[lyr-1] : screengrid_layer[lyr-1];
5366
5367 //first things first
5368 if(z>8||fakez>8) return;
5369
5370 //find out which combo row/column the coordinates are in
5371 bx &= 0xF0;
5372 by &= 0xF0;
5373
5374 int32_t type = scr_cmb.type;
5375 int32_t flag = MAPFLAGL(lyr,bx,by);
5376 int32_t flag2 = scr_cmb.flag;
5377 int32_t i = (bx>>4) + by;
5378
5379 if(i > 175)
5380 return;
5381
5382 bool pound=false;
5383
5384 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5385 return;
5386
5387 if(get_bit(grid, i) != 0)
5388 return;
5389
5390 mapscr *s = FFCore.tempScreens[lyr];
5391
5392 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5393 {
5394 findentrance(bx,by,mfHAMMER,true);
5395 findentrance(bx,by,mfSTRIKE,true);
5396 }
5397 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5398 {
5399 findentrance(bx,by,mfHAMMER,true);
5400 findentrance(bx,by,mfSTRIKE,true);
5401 }
5402 else if((flag >= 16)&&(flag <= 31))
5403 {
5404 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5405 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5406 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5407 }
5408 else if(flag == mfARMOS_SECRET)
5409 {
5410 s->data[i] = s->secretcombo[sSTAIRS];
5411 s->cset[i] = s->secretcset[sSTAIRS];
5412 s->sflag[i] = s->secretflag[sSTAIRS];
5413 sfx(tmpscr->secretsfx);
5414 }
5415 else if((flag2 >= 16)&&(flag2 <= 31))
5416 {
5417 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5418 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5419 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5420 }
5421 else if(flag2 == mfARMOS_SECRET)
5422 {
5423 s->data[i] = s->secretcombo[sSTAIRS];
5424 s->cset[i] = s->secretcset[sSTAIRS];
5425 s->sflag[i] = s->secretflag[sSTAIRS];
5426 sfx(tmpscr->secretsfx);
5427 }
5428 else pound = true;
5429
5430 if(pound)
5431 s->data[i]+=1;
5432
5433 set_bit(grid,i,1);
5434
5435 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5436 {
5437 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5438 sfx(tmpscr->secretsfx);
5439 }
5440
5441 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5442 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5443
5444 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5445 }
5446
5447 void HeroClass::check_wand_block(weapon *w)
5448 {
5449
5450 int32_t par_item = w->parentitem;
5451 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5452 int32_t usewpn = -1;
5453 if ( par_item > -1 )
5454 {
5455 usewpn = itemsbuf[par_item].useweapon;
5456 }
5457 else if ( par_item == -1 && w->ScriptGenerated )
5458 {
5459 usewpn = w->useweapon;
5460 }
5461 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5462 if(usewpn != wWand) return;
5463
5464
5465 int32_t bx = 0, by = 0;
5466 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5467 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5468
5469 //keep things inside the screen boundaries
5470 bx=vbound(bx, 0, 255);
5471 by=vbound(by, 0, 176);
5472 int32_t fx=vbound(bx, 0, 255);
5473 int32_t fy=vbound(by, 0, 176);
5474 int32_t cid = MAPCOMBO(bx,by);
5475 //first things first
5476 if(z>8||fakez>8) return;
5477
5478 //find out which combo row/column the coordinates are in
5479 bx &= 0xF0;
5480 by &= 0xF0;
5481
5482 int32_t flag = MAPFLAG(bx,by);
5483 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5484 int32_t flag3=0;
5485 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5486 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5487 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5488 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5489
5490 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5491 flag3=mfWAND;
5492
5493 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5494 flag3=mfSTRIKE;
5495
5496 int32_t i = (bx>>4) + by;
5497
5498 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5499 return;
5500
5501 if(i > 175)
5502 return;
5503
5504 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5505
5506 //findentrance(bx,by,mfWAND,true);
5507 //findentrance(bx,by,mfSTRIKE,true);
5508 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5509 {
5510 if(flag3==mfWAND||flag3==mfSTRIKE)
5511 {
5512 findentrance(fx,fy,mfWAND,true);
5513 findentrance(fx,fy,mfSTRIKE,true);
5514 }
5515 }
5516
5517 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5518 }
5519
5520 //defend results should match defence types.
5521 //RETURN VALUES:
5522 // -1 iGNORE WEAPON
5523 // 0 No effects
5524 // 1 Effects, weapon is not ignored or removed
5525 6603 int32_t HeroClass::defend(weapon *w)
5526 {
5527 6603 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5528
1/25
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
6603 switch(def)
5529 {
5530 6603 case edNORMAL: return 1;
5531 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5532 {
5533 w->power *= 0.5;
5534 return 1;
5535 }
5536 case edQUARTDAMAGE:
5537 {
5538 w->power *= 0.25;
5539 return 1;
5540 }
5541 case edSTUNONLY:
5542 {
5543 setStunClock(120);
5544 return 1;
5545 }
5546 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5547 {
5548 if (w->power > 0)
5549 {
5550 setStunClock(120);
5551 return 1;
5552 }
5553 else
5554 {
5555 sfx(WAV_CHINK,pan(int32_t(x)));
5556 w->dead = 0;
5557 return -1;
5558 }
5559 }
5560 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5561 {
5562 if (w->power > 0)
5563 {
5564 setStunClock(120);
5565 return 1;
5566 }
5567 else
5568 {
5569 return -1;
5570 }
5571 }
5572 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5573 {
5574 if (w->power < 1)
5575 {
5576 sfx(WAV_CHINK,pan(int32_t(x)));
5577 w->dead = 0;
5578 return -1;
5579 }
5580 else
5581 {
5582 return 1;
5583 }
5584 }
5585 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5586 {
5587 if (w->power < 2)
5588 {
5589 sfx(WAV_CHINK,pan(int32_t(x)));
5590 w->dead = 0;
5591 return -1;
5592 }
5593 else
5594 {
5595 return 1;
5596 }
5597 }
5598 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5599 {
5600 if (w->power < 4)
5601 {
5602 sfx(WAV_CHINK,pan(int32_t(x)));
5603 w->dead = 0;
5604 return -1;
5605 }
5606 else
5607 {
5608 return 1;
5609 }
5610 }
5611 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5612 {
5613 if (w->power < 6)
5614 {
5615 sfx(WAV_CHINK,pan(int32_t(x)));
5616 w->dead = 0;
5617 return -1;
5618 }
5619 else
5620 {
5621 return 1;
5622 }
5623 }
5624 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5625 {
5626 if (w->power < 8)
5627 {
5628 sfx(WAV_CHINK,pan(int32_t(x)));
5629 w->dead = 0;
5630 return -1;
5631 }
5632 else
5633 {
5634 return 1;
5635 }
5636 }
5637 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5638 {
5639 sfx(WAV_CHINK,pan(int32_t(x)));
5640 w->dead = 0;
5641 return -1;
5642 }
5643 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5644 {
5645 if (w->power < 1)
5646 {
5647 return -1;
5648 }
5649 else return 1;
5650 }
5651 case edIGNORE: // : IMPLEMENTED : Do Nothing
5652 {
5653 return -1;
5654 }
5655 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5656 {
5657 game->set_life(0);
5658 return 1;
5659 }
5660 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5661 {
5662 if (w->power < 10)
5663 {
5664 sfx(WAV_CHINK,pan(int32_t(x)));
5665 w->dead = 0;
5666 return -1;
5667 }
5668 else
5669 {
5670 return 1;
5671 }
5672 }
5673 case ed2x: // : IMPLEMENTED : Double damage.
5674 {
5675 w->power *= 2;
5676 return 1;
5677 }
5678 case ed3x: // : IMPLEMENTED : Triple Damage.
5679 {
5680 w->power *= 3;
5681 return 1;
5682 }
5683 case ed4x: // : IMPLEMENTED : 4x damage.
5684 {
5685 w->power *= 4;
5686 return 1;
5687 }
5688 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5689 {
5690 //sfx(WAV_HEAL,pan(int32_t(x)));
5691 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5692 w->dead = 0;
5693 return -1;
5694 }
5695
5696 case edFREEZE: return 1; //Not IMPLEMENTED
5697
5698 case edLEVELDAMAGE: //Damage * item level
5699 {
5700 w->power *= w->family_level;
5701 return 1;
5702 }
5703 case edLEVELREDUCTION: //Damage / item level
5704 {
5705 if ( w->family_level > 0 )
5706 {
5707 w->power /= w->family_level;
5708 }
5709 else w->power = 0;
5710 return 1;
5711 }
5712
5713 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5714 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5715 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5716 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5717
5718 //edSHOCK, //buzz blob
5719
5720
5721 case edBREAKSHIELD: //destroy the player's present shield
5722 {
5723 w->power = 0;
5724 w->dead = 0;
5725 int32_t itemid = getCurrentShield();
5726 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5727 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5728 game->set_item(itemid, false);
5729 //Remove Hero's shield
5730 return -1;
5731 }
5732
5733
5734
5735 default: return 0;
5736 }
5737 6603 }
5738 ALLEGRO_COLOR HeroClass::hitboxColor(byte opacity) const
5739 {
5740 return al_map_rgba(0,0,255,opacity);
5741 }
5742 6401 int32_t HeroClass::compareDir(int32_t other)
5743 {
5744
5/6
✓ Branch 0 taken 6396 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6396 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 6399 times.
6401 if(other != NORMAL_DIR(other))
5745 2 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5746 6399 int32_t ret = 0;
5747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6399 times.
6399 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5748
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
✓ Branch 2 taken 1045 times.
✓ Branch 3 taken 2004 times.
✓ Branch 4 taken 1982 times.
6399 switch(d)
5749 {
5750 case up:
5751 {
5752
3/3
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 526 times.
✓ Branch 2 taken 519 times.
1368 switch(X_DIR(other))
5753 {
5754 case left:
5755 526 ret |= CMPDIR_RIGHT;
5756 526 break;
5757 case right:
5758 519 ret |= CMPDIR_LEFT;
5759 519 break;
5760 }
5761
3/3
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 229 times.
✓ Branch 2 taken 980 times.
1368 switch(Y_DIR(other))
5762 {
5763 case up:
5764 229 ret |= CMPDIR_BACK;
5765 229 break;
5766 case down:
5767 980 ret |= CMPDIR_FRONT;
5768 980 break;
5769 }
5770 1368 break;
5771 }
5772 case down:
5773 {
5774
3/3
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 405 times.
1045 switch(X_DIR(other))
5775 {
5776 case left:
5777 330 ret |= CMPDIR_LEFT;
5778 330 break;
5779 case right:
5780 405 ret |= CMPDIR_RIGHT;
5781 405 break;
5782 }
5783
3/3
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 731 times.
✓ Branch 2 taken 180 times.
1045 switch(Y_DIR(other))
5784 {
5785 case up:
5786 731 ret |= CMPDIR_FRONT;
5787 731 break;
5788 case down:
5789 180 ret |= CMPDIR_BACK;
5790 180 break;
5791 }
5792 1045 break;
5793 }
5794 case left:
5795 {
5796
3/3
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 1620 times.
2004 switch(X_DIR(other))
5797 {
5798 case left:
5799 293 ret |= CMPDIR_BACK;
5800 293 break;
5801 case right:
5802 1620 ret |= CMPDIR_FRONT;
5803 1620 break;
5804 }
5805
3/3
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 674 times.
2004 switch(Y_DIR(other))
5806 {
5807 case up:
5808 613 ret |= CMPDIR_LEFT;
5809 613 break;
5810 case down:
5811 674 ret |= CMPDIR_RIGHT;
5812 674 break;
5813 }
5814 2004 break;
5815 }
5816 case right:
5817 {
5818
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 1630 times.
✓ Branch 2 taken 259 times.
1982 switch(X_DIR(other))
5819 {
5820 case left:
5821 1630 ret |= CMPDIR_FRONT;
5822 1630 break;
5823 case right:
5824 259 ret |= CMPDIR_BACK;
5825 259 break;
5826 }
5827
3/3
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 510 times.
✓ Branch 2 taken 715 times.
1982 switch(Y_DIR(other))
5828 {
5829 case up:
5830 510 ret |= CMPDIR_RIGHT;
5831 510 break;
5832 case down:
5833 715 ret |= CMPDIR_LEFT;
5834 715 break;
5835 }
5836 1982 break;
5837 }
5838 }
5839 6399 return ret;
5840 6401 }
5841
5842 6401 bool compareShield(int32_t cmpdir, itemdata const& shield)
5843 {
5844
1/2
✓ Branch 0 taken 6401 times.
✗ Branch 1 not taken.
6401 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
5845
1/2
✓ Branch 0 taken 6401 times.
✗ Branch 1 not taken.
6401 if(standard) //Use standard sides, either a passive shield, or a held active shield
5846 {
5847
3/4
✓ Branch 0 taken 4961 times.
✓ Branch 1 taken 1440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4961 times.
6401 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
5848 4961 return true;
5849
3/4
✓ Branch 0 taken 961 times.
✓ Branch 1 taken 479 times.
✓ Branch 2 taken 961 times.
✗ Branch 3 not taken.
1440 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
5850 return true;
5851
3/4
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 833 times.
✓ Branch 2 taken 607 times.
✗ Branch 3 not taken.
1440 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
5852 return true;
5853
3/4
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 645 times.
1440 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
5854 return true;
5855 1440 }
5856 else //Active Shield that is NOT held down
5857 {
5858 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
5859 return true;
5860 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
5861 return true;
5862 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
5863 return true;
5864 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
5865 return true;
5866 }
5867 1440 return false;
5868 6401 }
5869
5870 5752442 int32_t HeroClass::EwpnHit()
5871 {
5872
2/2
✓ Branch 0 taken 5749551 times.
✓ Branch 1 taken 4053865 times.
9803416 for(int32_t i=0; i<Ewpns.Count(); i++)
5873 {
5874
2/2
✓ Branch 0 taken 4047262 times.
✓ Branch 1 taken 6603 times.
4053865 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
5875 {
5876 6603 weapon *ew = (weapon*)(Ewpns.spr(i));
5877
5878
3/6
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6603 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6603 times.
6603 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
5879 break;
5880
5881 6603 int32_t stompid = current_item_id(itype_stompboots);
5882
5883
5/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6597 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6603 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
5884
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((z+fakez) > (ew->z+(ew->fakez))) ||
5885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
5886 {
5887 itemdata const& stomp = itemsbuf[stompid];
5888 bool remove = false;
5889 switch(ew->id)
5890 {
5891 case ewFireball2:
5892 case ewFireball:
5893 if(ew->type & 1) //Boss fireball
5894 {
5895 if(stomp.misc2 & (shFIREBALL2))
5896 remove = true;
5897 }
5898 else
5899 {
5900 if(stomp.misc2 & (shFIREBALL))
5901 remove = true;
5902 }
5903
5904 break;
5905
5906 case ewMagic:
5907 if((stomp.misc2 & shMAGIC))
5908 remove = true;
5909 break;
5910
5911 case ewSword:
5912 if((stomp.misc2 & shSWORD))
5913 remove = true;
5914
5915 break;
5916
5917 case ewFlame:
5918 if((stomp.misc2 & shFLAME))
5919 remove = true;
5920
5921 break;
5922
5923 case ewRock:
5924 if((stomp.misc2 & shROCK))
5925 remove = true;
5926
5927 break;
5928
5929 case ewArrow:
5930 if((stomp.misc2 & shARROW))
5931 remove = true;
5932
5933 break;
5934
5935 case ewBrang:
5936 if((stomp.misc2 & shBRANG))
5937 remove = true;
5938
5939 break;
5940
5941 default: // Just throw the script weapons in here...
5942 if(ew->id>=wScript1 && ew->id<=wScript10)
5943 {
5944 if((stomp.misc2 & shSCRIPT))
5945 remove = true;
5946 }
5947
5948 break;
5949 }
5950 if (remove)
5951 {
5952 ew->onhit(false);
5953 sfx(WAV_CHINK,pan(x.getInt()));
5954 continue;
5955 }
5956 }
5957
5958 6603 int32_t defresult = defend(ew);
5959
1/2
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
6603 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
5960
5961
2/2
✓ Branch 0 taken 6602 times.
✓ Branch 1 taken 1 times.
6603 if(ew->id==ewWind)
5962 {
5963 1 xofs=1000;
5964 1 action=freeze; FFCore.setHeroAction(freeze);
5965 1 ew->misc=999; // in enemy wind
5966 1 attackclk=0;
5967 1 return -1;
5968 }
5969
5970
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6591 times.
6602 switch(ew->id)
5971 {
5972 case ewLitBomb:
5973 case ewBomb:
5974 case ewLitSBomb:
5975 case ewSBomb:
5976 11 return i;
5977 }
5978
5979 6591 int32_t itemid = getCurrentShield(false);
5980
4/6
✓ Branch 0 taken 6399 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 6399 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6399 times.
6591 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
5981 192 return i;
5982 6399 itemdata const& shield = itemsbuf[itemid];
5983 6399 bool allow_inactive = (shield.flags & ITEM_FLAG9);
5984 6399 auto cmpdir = compareDir(ew->dir);
5985 6399 bool hitshield = compareShield(cmpdir, shield);
5986
5987
12/20
✓ Branch 0 taken 6399 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6399 times.
✓ Branch 4 taken 5133 times.
✓ Branch 5 taken 1266 times.
✓ Branch 6 taken 5133 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5105 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 5105 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5105 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5105 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 5105 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5105 times.
✗ Branch 19 not taken.
6399 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
5988 1294 return i;
5989
5990
2/2
✓ Branch 0 taken 4061 times.
✓ Branch 1 taken 1044 times.
5105 if(!hitshield)
5991 1044 return i;
5992
5993 4061 paymagiccost(itemid);
5994
5995 4061 bool reflect = false;
5996
5997
7/8
✓ Branch 0 taken 2227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 545 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 349 times.
✓ Branch 5 taken 232 times.
✓ Branch 6 taken 227 times.
✓ Branch 7 taken 211 times.
4061 switch(ew->id)
5998 {
5999 case ewFireball2:
6000 case ewFireball:
6001
2/2
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 2076 times.
2227 if(ew->type & 1) //Boss fireball
6002 {
6003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(!(shield.misc1 & (shFIREBALL2)))
6004 151 return i;
6005
6006 reflect = ((shield.misc2 & shFIREBALL2) != 0);
6007 }
6008 else
6009 {
6010
2/2
✓ Branch 0 taken 1978 times.
✓ Branch 1 taken 98 times.
2076 if(!(shield.misc1 & (shFIREBALL)))
6011 98 return i;
6012
6013 1978 reflect = ((shield.misc2 & shFIREBALL) != 0);
6014 }
6015
6016 1978 break;
6017
6018 case ewMagic:
6019
2/2
✓ Branch 0 taken 517 times.
✓ Branch 1 taken 28 times.
545 if(!(shield.misc1 & shMAGIC))
6020 28 return i;
6021
6022 517 reflect = ((shield.misc2 & shMAGIC) != 0);
6023 517 break;
6024
6025 case ewSword:
6026
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 26 times.
270 if(!(shield.misc1 & shSWORD))
6027 26 return i;
6028
6029 244 reflect = ((shield.misc2 & shSWORD) != 0);
6030 244 break;
6031
6032 case ewFlame:
6033
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 46 times.
349 if(!(shield.misc1 & shFLAME))
6034 46 return i;
6035
6036 303 reflect = ((shield.misc2 & shFLAME) != 0); // Actually isn't reflected.
6037 303 break;
6038
6039 case ewRock:
6040
1/2
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
232 if(!(shield.misc1 & shROCK))
6041 return i;
6042
6043 232 reflect = (shield.misc2 & shROCK);
6044 232 break;
6045
6046 case ewArrow:
6047
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 if(!(shield.misc1 & shARROW))
6048 return i;
6049
6050 227 reflect = ((shield.misc2 & shARROW) != 0); // Actually isn't reflected.
6051 227 break;
6052
6053 case ewBrang:
6054
1/2
✓ Branch 0 taken 211 times.
✗ Branch 1 not taken.
211 if(!(shield.misc1 & shBRANG))
6055 return i;
6056
6057 211 break;
6058
6059 default: // Just throw the script weapons in here...
6060 if(ew->id>=wScript1 && ew->id<=wScript10)
6061 {
6062 if(!(shield.misc1 & shSCRIPT))
6063 return i;
6064
6065 reflect = ((shield.misc2 & shSCRIPT) != 0);
6066 }
6067
6068 break;
6069 }
6070
6071
3/4
✓ Branch 0 taken 1097 times.
✓ Branch 1 taken 2615 times.
✓ Branch 2 taken 1097 times.
✗ Branch 3 not taken.
3712 if(reflect && (ew->unblockable&WPNUNB_REFL))
6072 reflect = false;
6073
3/4
✓ Branch 0 taken 2615 times.
✓ Branch 1 taken 1097 times.
✓ Branch 2 taken 2615 times.
✗ Branch 3 not taken.
3712 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6074 return i;
6075
6076 3712 int32_t oldid = ew->id;
6077 3712 ew->onhit(false, reflect ? 2 : 1, dir);
6078
6079
2/2
✓ Branch 0 taken 2615 times.
✓ Branch 1 taken 1097 times.
3712 if(ew->id != oldid) // changed type from ewX to wX
6080 {
6081 // ew->power*=game->get_hero_dmgmult();
6082 1097 Lwpns.add(ew);
6083 1097 Ewpns.remove(ew);
6084 1097 ew->isLWeapon = true; //Make sure this gets set everywhere!
6085 1097 }
6086
6087
2/2
✓ Branch 0 taken 3373 times.
✓ Branch 1 taken 339 times.
3712 if(ew->id==wRefMagic)
6088 {
6089 339 ew->ignoreHero=true;
6090 339 ew->ignorecombo=-1;
6091 339 }
6092
6093 3712 sfx(shield.usesound,pan(x.getInt()));
6094 3712 }
6095 4050974 }
6096
6097 5749551 return -1;
6098 5752442 }
6099
6100 5752444 int32_t HeroClass::LwpnHit() //only here to check magic hits
6101 {
6102
2/2
✓ Branch 0 taken 5643255 times.
✓ Branch 1 taken 2348268 times.
7991523 for(int32_t i=0; i<Lwpns.Count(); i++)
6103
2/2
✓ Branch 0 taken 2239079 times.
✓ Branch 1 taken 109189 times.
2348268 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6104 {
6105 109189 weapon *lw = (weapon*)(Lwpns.spr(i));
6106
6107
2/2
✓ Branch 0 taken 105952 times.
✓ Branch 1 taken 3237 times.
109189 if((lw->ignoreHero)==true)
6108 3237 break;
6109
6110
5/8
✓ Branch 0 taken 105952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105950 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 105950 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 105950 times.
105952 if (!(lw->id == wRefFireball || lw->id == wRefMagic || lw->id == wRefBeam || lw->id == wRefRock)) return -1;
6111 2 int32_t itemid = getCurrentShield(false);
6112
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6113 return i;
6114 2 itemdata const& shield = itemsbuf[itemid];
6115 2 auto cmpdir = compareDir(lw->dir);
6116 2 bool hitshield = compareShield(cmpdir, shield);
6117 2 bool reflect = false;
6118
6119
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 switch(lw->id)
6120 {
6121 case wRefFireball:
6122 if(itemid<0)
6123 return i;
6124
6125 if(lw->type & 1) //Boss fireball
6126 return i;
6127
6128 if(!(shield.misc1 & (shFIREBALL)))
6129 return i;
6130
6131 reflect = ((shield.misc2 & shFIREBALL) != 0);
6132 break;
6133
6134 case wRefMagic:
6135
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemid<0)
6136 return i;
6137
6138
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(shield.misc1 & shMAGIC))
6139 return i;
6140
6141 2 reflect = ((shield.misc2 & shMAGIC) != 0);
6142 2 break;
6143
6144 case wRefBeam:
6145 if(itemid<0)
6146 return i;
6147
6148 if(!(shield.misc1 & shSWORD))
6149 return i;
6150
6151 reflect = ((shield.misc2 & shSWORD) != 0);
6152 break;
6153
6154 case wRefRock:
6155 if(itemid<0)
6156 return i;
6157
6158 if(!(shield.misc1 & shROCK))
6159 return i;
6160
6161 reflect = (shield.misc2 & shROCK);
6162 break;
6163
6164 default:
6165 return -1;
6166 }
6167
6168 2 bool allow_inactive = (shield.flags & ITEM_FLAG9);
6169
10/20
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
2 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6170 return i;
6171
6172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!hitshield)
6173 2 return i;
6174
6175 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6176
6177 paymagiccost(itemid);
6178
6179 lw->onhit(false, 1+reflect, dir);
6180 lw->ignoreHero=true;
6181 lw->ignorecombo=-1;
6182 sfx(shield.usesound,pan(x.getInt()));
6183 }
6184
6185 5646492 return -1;
6186 5752444 }
6187
6188 10107237 void HeroClass::checkhit()
6189 {
6190
2/2
✓ Branch 0 taken 3688678 times.
✓ Branch 1 taken 6418559 times.
10107237 if(checkhero==true)
6191 {
6192
2/2
✓ Branch 0 taken 6097513 times.
✓ Branch 1 taken 321046 times.
6418559 if(hclk>0)
6193 {
6194 321046 --hclk;
6195 321046 }
6196
6197
1/2
✓ Branch 0 taken 6418559 times.
✗ Branch 1 not taken.
6418559 if(DivineProtectionShieldClk>0)
6198 {
6199 --DivineProtectionShieldClk;
6200
6201 if(DivineProtectionShieldClk == 0 && div_prot_item != -1)
6202 {
6203 stop_sfx(itemsbuf[div_prot_item].usesound);
6204 stop_sfx(itemsbuf[div_prot_item].usesound+1);
6205 div_prot_item = -1;
6206 }
6207 else if(get_bit(quest_rules,qr_MORESOUNDS) && !(DivineProtectionShieldClk&0xF00) && div_prot_item != -1)
6208 {
6209 stop_sfx(itemsbuf[div_prot_item].usesound);
6210 cont_sfx(itemsbuf[div_prot_item].usesound+1);
6211 }
6212 }
6213 6418559 }
6214
6215
4/4
✓ Branch 0 taken 6357541 times.
✓ Branch 1 taken 3749696 times.
✓ Branch 2 taken 6353815 times.
✓ Branch 3 taken 3726 times.
10107237 if(hclk<39 && action==gothit)
6216 {
6217 3726 action=none; FFCore.setHeroAction(none);
6218 3726 }
6219
6220
5/6
✓ Branch 0 taken 6357541 times.
✓ Branch 1 taken 3749696 times.
✓ Branch 2 taken 6357489 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6357489 times.
10107237 if(hclk<39 && (action==swimhit || action == sideswimhit))
6221 {
6222 52 SetSwim();
6223 52 }
6224
6225
4/4
✓ Branch 0 taken 54261 times.
✓ Branch 1 taken 10052976 times.
✓ Branch 2 taken 14607 times.
✓ Branch 3 taken 39654 times.
10107237 if(hclk>=40 && action==gothit)
6226 {
6227 39654 int val = check_pitslide();
6228
4/4
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 39372 times.
✓ Branch 2 taken 39774 times.
✓ Branch 3 taken 39492 times.
39654 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6229 {
6230
2/2
✓ Branch 0 taken 159096 times.
✓ Branch 1 taken 39774 times.
198870 for(int32_t i=0; i<4; i++)
6231 {
6232
5/5
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 34572 times.
✓ Branch 2 taken 38344 times.
✓ Branch 3 taken 41084 times.
✓ Branch 4 taken 44904 times.
159096 switch(hitdir)
6233 {
6234 case up:
6235
6/6
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 32388 times.
✓ Branch 2 taken 30154 times.
✓ Branch 3 taken 2234 times.
✓ Branch 4 taken 2196 times.
✓ Branch 5 taken 32376 times.
34572 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6236 {
6237 2196 action=none; FFCore.setHeroAction(none);
6238 2196 }
6239
2/2
✓ Branch 0 taken 32372 times.
✓ Branch 1 taken 4 times.
32376 else if (val == -1) --y;
6240
6241 34572 break;
6242
6243 case down:
6244
6/6
✓ Branch 0 taken 3031 times.
✓ Branch 1 taken 35313 times.
✓ Branch 2 taken 2360 times.
✓ Branch 3 taken 32953 times.
✓ Branch 4 taken 3059 times.
✓ Branch 5 taken 35285 times.
38344 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6245 {
6246 3059 action=none; FFCore.setHeroAction(none);
6247 3059 }
6248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35285 times.
35285 else if (val == -1) ++y;
6249
6250 38344 break;
6251
6252 case left:
6253
7/8
✓ Branch 0 taken 39695 times.
✓ Branch 1 taken 1389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39695 times.
✓ Branch 4 taken 926 times.
✓ Branch 5 taken 38769 times.
✓ Branch 6 taken 1393 times.
✓ Branch 7 taken 39691 times.
41084 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6254 {
6255 1393 action=none; FFCore.setHeroAction(none);
6256 1393 }
6257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39691 times.
39691 else if (val == -1) --x;
6258
6259 41084 break;
6260
6261 case right:
6262
7/8
✓ Branch 0 taken 43202 times.
✓ Branch 1 taken 1702 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43202 times.
✓ Branch 4 taken 42593 times.
✓ Branch 5 taken 609 times.
✓ Branch 6 taken 1714 times.
✓ Branch 7 taken 43190 times.
44904 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6263 {
6264 1714 action=none; FFCore.setHeroAction(none);
6265 1714 }
6266
1/2
✓ Branch 0 taken 43190 times.
✗ Branch 1 not taken.
43190 else if (val == -1) ++x;
6267
6268 44904 break;
6269 }
6270 159096 }
6271 39774 }
6272 39894 }
6273
6274
18/20
✓ Branch 0 taken 6104086 times.
✓ Branch 1 taken 4003391 times.
✓ Branch 2 taken 6103887 times.
✓ Branch 3 taken 199 times.
✓ Branch 4 taken 6094187 times.
✓ Branch 5 taken 9700 times.
✓ Branch 6 taken 6093547 times.
✓ Branch 7 taken 640 times.
✓ Branch 8 taken 6093547 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6093547 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6093399 times.
✓ Branch 13 taken 148 times.
✓ Branch 14 taken 6089520 times.
✓ Branch 15 taken 3879 times.
✓ Branch 16 taken 4915 times.
✓ Branch 17 taken 6084605 times.
✓ Branch 18 taken 4322779 times.
✓ Branch 19 taken 4327694 times.
10107477 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6275 {
6276 8340736 return;
6277 }
6278
6279
2/2
✓ Branch 0 taken 6865004 times.
✓ Branch 1 taken 6084506 times.
12949510 for(int32_t i=0; i<Lwpns.Count(); i++)
6280 {
6281 6865004 sprite *s = Lwpns.spr(i);
6282 6865004 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6283 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6284 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6285
13/14
✓ Branch 0 taken 396935 times.
✓ Branch 1 taken 6468069 times.
✓ Branch 2 taken 2140375 times.
✓ Branch 3 taken 4327694 times.
✓ Branch 4 taken 2140375 times.
✓ Branch 5 taken 2187319 times.
✓ Branch 6 taken 2116200 times.
✓ Branch 7 taken 71119 times.
✓ Branch 8 taken 2116200 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 80797 times.
✓ Branch 11 taken 2035403 times.
✓ Branch 12 taken 40325 times.
✓ Branch 13 taken 41840 times.
6865004 if((!(itemid==-1&&get_bit(quest_rules,qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && (scriptcoldet&1) && !fallclk && (!superman || !get_bit(quest_rules,qr_FIREPROOFHERO2)))
6286 {
6287
9/10
✓ Branch 0 taken 2005284 times.
✓ Branch 1 taken 71959 times.
✓ Branch 2 taken 71610 times.
✓ Branch 3 taken 349 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 349 times.
✓ Branch 6 taken 360 times.
✓ Branch 7 taken 71250 times.
✓ Branch 8 taken 2076534 times.
✓ Branch 9 taken 25 times.
2077268 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6288
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
709 (itemid < 0 || itemsbuf[itemid].family!=itype_divinefire))
6289 {
6290 25 std::vector<int32_t> &ev = FFCore.eventData;
6291 25 ev.clear();
6292 25 ev.push_back(lwpn_dp(i)*10000);
6293 25 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6294 25 ev.push_back(0);
6295 25 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6296 25 ev.push_back(48*10000);
6297 25 ev.push_back(ZSD_LWPN*10000);
6298 25 ev.push_back(s->getUID());
6299
6300 25 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6301 25 int32_t dmg = ev[0]/10000;
6302 25 bool nullhit = ev[2] != 0;
6303
6304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(nullhit) {ev.clear(); return;}
6305
6306 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6307 25 ev[0] = ringpower(dmg)*10000;
6308
6309 25 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6310 25 dmg = ev[0]/10000;
6311 25 int32_t hdir = ev[1]/10000;
6312 25 nullhit = ev[2] != 0;
6313 25 bool divineprot = ev[3] != 0;
6314 25 int32_t iframes = ev[4] / 10000;
6315 25 ev.clear();
6316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(nullhit) return;
6317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!divineprot)
6318 {
6319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 game->set_life(zc_max(game->get_life()-dmg,0));
6320
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (!get_bit(quest_rules, qr_BROKENHITBY))
6321 {
6322 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6323 if (get_bit(quest_rules, qr_BROKENHITBY))
6324 {
6325 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6326 }
6327 else
6328 {
6329
6330 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getScriptUID());
6331 }
6332 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6333 sethitHeroUID(HIT_BY_LWEAPON_TYPE, ((weapon*)(Lwpns.spr(i)))->id);
6334 if (((weapon*)(Lwpns.spr(i)))->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, ((weapon*)(Lwpns.spr(i)))->parentitem);
6335 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6336 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[((weapon*)(Lwpns.spr(i)))->parentitem].family);
6337 }
6338 25 }
6339
6340 25 hitdir = hdir;
6341
6342
3/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
25 if (action != rafting && action != freeze && action != sideswimfreeze)
6343 {
6344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if (IsSideSwim())
6345 {
6346 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6347 }
6348
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 else if (action == swimming || hopclk == 0xFF)
6349 {
6350 action=swimhit; FFCore.setHeroAction(swimhit);
6351 }
6352 else
6353 {
6354 25 action=gothit; FFCore.setHeroAction(gothit);
6355 }
6356 25 }
6357
6358
5/8
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
25 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6359 {
6360 5 spins = charging = attackclk = 0;
6361 5 attack=none;
6362 5 tapping = false;
6363 5 }
6364
6365 25 hclk=iframes;
6366 25 sfx(getHurtSFX(),pan(x.getInt()));
6367 25 return;
6368 }
6369 2076534 }
6370
6371 // check enemy weapons true, 1, -1
6372 //
6373
2/2
✓ Branch 0 taken 2519504 times.
✓ Branch 1 taken 17781 times.
2584913 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6374 {
6375
6/6
✓ Branch 0 taken 1717 times.
✓ Branch 1 taken 16064 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 1558 times.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 100 times.
17781 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6376 {
6377
1/2
✓ Branch 0 taken 16164 times.
✗ Branch 1 not taken.
16164 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6378 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6379 16164 itemid = vbound(itemid, 0, MAXITEMS-1);
6380
6381
2/2
✓ Branch 0 taken 16160 times.
✓ Branch 1 taken 1039 times.
17199 for(int32_t j=0; j<Ewpns.Count(); j++)
6382 {
6383 1039 sprite *t = Ewpns.spr(j);
6384
6385
2/2
✓ Branch 0 taken 1035 times.
✓ Branch 1 taken 4 times.
1039 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6386 {
6387 4 bool reflect = false;
6388 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6389
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
4 switch(t->id)
6390 {
6391 case ewBrang:
6392 if(!(itemsbuf[itemid].misc3 & shBRANG)) break;
6393
6394 reflect = ((itemsbuf[itemid].misc4 & shBRANG) != 0);
6395 goto killweapon;
6396
6397 case ewArrow:
6398 if(!(itemsbuf[itemid].misc3 & shARROW)) break;
6399
6400 reflect = ((itemsbuf[itemid].misc4 & shARROW) != 0);
6401 goto killweapon;
6402
6403 case ewRock:
6404 if(!(itemsbuf[itemid].misc3 & shROCK)) break;
6405
6406 reflect = ((itemsbuf[itemid].misc4 & shROCK) != 0);
6407 goto killweapon;
6408
6409 case ewFireball2:
6410 case ewFireball:
6411 {
6412 int32_t mask = (((weapon*)t)->type&1 ? shFIREBALL2 : shFIREBALL);
6413
6414 if(!(itemsbuf[itemid].misc3 & mask)) break;
6415
6416 reflect = ((itemsbuf[itemid].misc4 & mask) != 0);
6417 goto killweapon;
6418 }
6419
6420 case ewSword:
6421 if(!(itemsbuf[itemid].misc3 & shSWORD)) break;
6422
6423 reflect = ((itemsbuf[itemid].misc4 & shSWORD) != 0);
6424 goto killweapon;
6425
6426 case wRefMagic:
6427 case ewMagic:
6428 if(!(itemsbuf[itemid].misc3 & shMAGIC)) break;
6429
6430 reflect = ((itemsbuf[itemid].misc4 & shMAGIC) != 0);
6431 goto killweapon;
6432
6433 case wScript1:
6434 case wScript2:
6435 case wScript3:
6436 case wScript4:
6437 case wScript5:
6438 case wScript6:
6439 case wScript7:
6440 case wScript8:
6441 case wScript9:
6442 case wScript10:
6443 if(!(itemsbuf[itemid].misc3 & shSCRIPT)) break;
6444
6445 reflect = ((itemsbuf[itemid].misc4 & shSCRIPT) != 0);
6446 goto killweapon;
6447
6448 case ewLitBomb:
6449 case ewLitSBomb:
6450 killweapon:
6451 ((weapon*)s)->dead=1;
6452 weapon *ew = ((weapon*)t);
6453 int32_t oldid = ew->id;
6454 ew->onhit(true, reflect ? 2 : 1, s->dir);
6455
6456 if(ew->id != oldid || (ew->id>=wScript1 && ew->id<=wScript10)) // changed type from ewX to wX... Except for script weapons
6457 {
6458 Lwpns.add(ew);
6459 Ewpns.remove(ew);
6460 ew->isLWeapon = true; //Make sure this gets set everywhere!
6461 }
6462
6463 if(ew->id==wRefMagic)
6464 {
6465 ew->ignoreHero=true;
6466 ew->ignorecombo=-1;
6467 }
6468
6469 break;
6470 }
6471
6472 4 break;
6473 }
6474 1035 }
6475 16164 }
6476 17781 }
6477
6478
6/6
✓ Branch 0 taken 1732960 times.
✓ Branch 1 taken 804325 times.
✓ Branch 2 taken 396935 times.
✓ Branch 3 taken 1336025 times.
✓ Branch 4 taken 32722 times.
✓ Branch 5 taken 364213 times.
2537285 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_bit(quest_rules,qr_OUCHBOMBS)))
6479 {
6480
6/8
✓ Branch 0 taken 830343 times.
✓ Branch 1 taken 6704 times.
✓ Branch 2 taken 6596 times.
✓ Branch 3 taken 830451 times.
✓ Branch 4 taken 6596 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6596 times.
837047 if(((s->id==wBomb)||(s->id==wSBomb)) && !superman && (scriptcoldet&1) && !fallclk)
6481 {
6482 6596 weapon* w = (weapon*)s;
6483 6596 bool didhit = s->hit(this);
6484
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 7 times.
6596 if(didhit)
6485 {
6486 7 std::vector<int32_t> &ev = FFCore.eventData;
6487 7 ev.clear();
6488
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 ev.push_back(((((weapon*)s)->parentitem>-1 ? itemsbuf[((weapon*)s)->parentitem].misc3 : ((weapon*)s)->power) *game->get_hp_per_heart())*10000);
6489 7 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6490 7 ev.push_back(0);
6491 7 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6492 7 ev.push_back(48*10000);
6493 7 ev.push_back(ZSD_LWPN*10000);
6494 7 ev.push_back(s->getUID());
6495
6496 7 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6497 7 int32_t dmg = ev[0]/10000;
6498 7 bool nullhit = ev[2] != 0;
6499
6500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(nullhit) {ev.clear(); return;}
6501
6502 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6503 7 ev[0] = ringpower(dmg)*10000;
6504
6505 7 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6506 7 dmg = ev[0]/10000;
6507 7 int32_t hdir = ev[1]/10000;
6508 7 nullhit = ev[2] != 0;
6509 7 bool divineprot = ev[3] != 0;
6510 7 int32_t iframes = ev[4] / 10000;
6511 7 ev.clear();
6512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(nullhit) return;
6513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(!divineprot)
6514 {
6515
3/6
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
7 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6516
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (!get_bit(quest_rules, qr_BROKENHITBY))
6517 {
6518 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6519 if (get_bit(quest_rules, qr_BROKENHITBY))
6520 {
6521 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6522 }
6523 else
6524 {
6525
6526 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getScriptUID());
6527 }
6528 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6529 sethitHeroUID(HIT_BY_LWEAPON_TYPE, ((weapon*)(Lwpns.spr(i)))->id);
6530 if (((weapon*)(Lwpns.spr(i)))->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, ((weapon*)(Lwpns.spr(i)))->parentitem);
6531 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6532 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[((weapon*)(Lwpns.spr(i)))->parentitem].family);
6533 }
6534 7 }
6535
6536 7 hitdir = hdir;
6537
6538
3/6
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
7 if (action != rafting && action != freeze && action != sideswimfreeze)
6539 {
6540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (IsSideSwim())
6541 {
6542 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6543 }
6544
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 else if (action == swimming || hopclk == 0xFF)
6545 {
6546 action=swimhit; FFCore.setHeroAction(swimhit);
6547 }
6548 else
6549 {
6550 7 action=gothit; FFCore.setHeroAction(gothit);
6551 }
6552 7 }
6553
6554
4/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7 times.
7 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6555 {
6556 spins = charging = attackclk = 0;
6557 attack=none;
6558 tapping = false;
6559 }
6560
6561 7 hclk=iframes;
6562 7 sfx(getHurtSFX(),pan(x.getInt()));
6563 7 return;
6564 }
6565 6589 }
6566 837040 }
6567
6568
7/8
✓ Branch 0 taken 2537278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6234 times.
✓ Branch 3 taken 2531044 times.
✓ Branch 4 taken 6167 times.
✓ Branch 5 taken 67 times.
✓ Branch 6 taken 2537211 times.
✓ Branch 7 taken 67 times.
2537278 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6569 {
6570 67 std::vector<int32_t> &ev = FFCore.eventData;
6571 67 ev.clear();
6572 67 ev.push_back(0);
6573 67 ev.push_back(s->dir*10000);
6574 67 ev.push_back(0);
6575 67 ev.push_back(0);
6576 67 ev.push_back(ZSD_LWPN*10000);
6577 67 ev.push_back(s->getUID());
6578
6579 67 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6580 67 bool nullhit = ev[2] != 0;
6581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(nullhit) {ev.clear(); return;}
6582
6583 67 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6584 67 int32_t hdir = ev[1]/10000;
6585 67 nullhit = ev[2] != 0;
6586 67 ev.clear();
6587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(nullhit) return;
6588
6589 67 reset_hookshot();
6590 67 xofs=1000;
6591 67 action=inwind; FFCore.setHeroAction(inwind);
6592 67 dir=s->dir=hdir;
6593 67 spins = charging = attackclk = 0;
6594
6595 // In case Hero used two whistles in a row, summoning two whirlwinds,
6596 // check which whistle's whirlwind picked him up so the correct
6597 // warp ring will be used
6598 67 int32_t whistle=((weapon*)s)->parentitem;
6599
6600
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
67 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6601 67 whistleitem=whistle;
6602
6603 67 return;
6604 }
6605 2537211 }
6606
6607
6/8
✓ Branch 0 taken 6020507 times.
✓ Branch 1 taken 63999 times.
✓ Branch 2 taken 5916349 times.
✓ Branch 3 taken 104158 times.
✓ Branch 4 taken 5916349 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5916349 times.
12000855 if(action==rafting || action==freeze || action==sideswimfreeze ||
6608
4/8
✓ Branch 0 taken 5916349 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5916349 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5916349 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5916349 times.
✗ Branch 7 not taken.
5916349 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6609 168157 return;
6610
6611 5916349 int32_t hit2 = -1;
6612 5916349 do
6613 {
6614
2/2
✓ Branch 0 taken 685592 times.
✓ Branch 1 taken 5236607 times.
5922199 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6615 5236607 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6616
6617
2/2
✓ Branch 0 taken 5908417 times.
✓ Branch 1 taken 13782 times.
5922199 if(hit2!=-1)
6618 {
6619
2/2
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 7932 times.
13782 if (hithero(hit2) == 0) return;
6620 5850 }
6621
2/2
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 5908417 times.
5914267 } while (hit2 != -1);
6622
6/6
✓ Branch 0 taken 5768691 times.
✓ Branch 1 taken 139726 times.
✓ Branch 2 taken 5752617 times.
✓ Branch 3 taken 16074 times.
✓ Branch 4 taken 173 times.
✓ Branch 5 taken 5752444 times.
5908417 if (superman || !(scriptcoldet&1) || fallclk) return;
6623 5752444 hit2 = LwpnHit();
6624
6625
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5752442 times.
5752444 if(hit2!=-1)
6626 {
6627 2 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6628 2 std::vector<int32_t> &ev = FFCore.eventData;
6629 2 ev.clear();
6630 2 ev.push_back((lwpn_dp(hit2)*10000));
6631 2 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6632 2 ev.push_back(0);
6633 2 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6634 2 ev.push_back(48*10000);
6635 2 ev.push_back(ZSD_LWPN*10000);
6636 2 ev.push_back(lwpnspr->getUID());
6637
6638 2 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6639 2 int32_t dmg = ev[0]/10000;
6640 2 bool nullhit = ev[2] != 0;
6641
6642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nullhit) {ev.clear(); return;}
6643
6644 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6645 2 ev[0] = ringpower(dmg)*10000;
6646
6647 2 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6648 2 dmg = ev[0]/10000;
6649 2 int32_t hdir = ev[1]/10000;
6650 2 nullhit = ev[2] != 0;
6651 2 bool divineprot = ev[3] != 0;
6652 2 int32_t iframes = ev[4] / 10000;
6653 2 ev.clear();
6654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nullhit) return;
6655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!divineprot)
6656 {
6657
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 game->set_life(zc_max(game->get_life()-dmg,0));
6658 2 sethitHeroUID(HIT_BY_LWEAPON,(hit2+1));
6659
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (get_bit(quest_rules, qr_BROKENHITBY))
6660 {
6661 2 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getUID());
6662 2 }
6663 else
6664 {
6665
6666 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getScriptUID());
6667 }
6668 2 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,lwpnspr->getUID());
6669 2 sethitHeroUID(HIT_BY_LWEAPON_TYPE, lwpnspr->id);
6670
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (lwpnspr->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, lwpnspr->parentitem);
6671 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6672 2 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[lwpnspr->parentitem].family);
6673 2 }
6674
6675 2 hitdir = hdir;
6676 2 lwpnspr->onhit(false);
6677
6678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (IsSideSwim())
6679 {
6680 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6681 }
6682
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 else if(action==swimming || hopclk==0xFF)
6683 {
6684 action=swimhit; FFCore.setHeroAction(swimhit);
6685 }
6686 else
6687 {
6688 2 action=gothit; FFCore.setHeroAction(gothit);
6689 }
6690
6691 2 hclk=iframes;
6692
6693
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
2 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6694 {
6695 spins = charging = attackclk = 0;
6696 attack=none;
6697 tapping = false;
6698 }
6699
6700 2 sfx(getHurtSFX(),pan(x.getInt()));
6701 2 return;
6702 }
6703
6704 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6705
6706 5752442 hit2 = EwpnHit();
6707
6708
2/2
✓ Branch 0 taken 2890 times.
✓ Branch 1 taken 5749552 times.
5752442 if(hit2!=-1)
6709 {
6710 2890 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6711 2890 std::vector<int32_t> &ev = FFCore.eventData;
6712 2890 ev.clear();
6713 2890 ev.push_back((ewpn_dp(hit2)*10000));
6714 2890 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6715 2890 ev.push_back(0);
6716 2890 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6717 2890 ev.push_back(48*10000);
6718 2890 ev.push_back(ZSD_EWPN*10000);
6719 2890 ev.push_back(ewpnspr->getUID());
6720
6721 2890 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6722 2890 int32_t dmg = ev[0]/10000;
6723 2890 bool nullhit = ev[2] != 0;
6724
6725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if(nullhit) {ev.clear(); return;}
6726
6727 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6728 2890 ev[0] = ringpower(dmg)*10000;
6729
6730 2890 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6731 2890 dmg = ev[0]/10000;
6732 2890 int32_t hdir = ev[1]/10000;
6733 2890 nullhit = ev[2] != 0;
6734 2890 bool divineprot = ev[3] != 0;
6735 2890 int32_t iframes = ev[4] / 10000;
6736 2890 ev.clear();
6737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if(nullhit) return;
6738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if(!divineprot)
6739 {
6740
2/2
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 19 times.
2890 game->set_life(zc_max(game->get_life()-dmg,0));
6741 2890 sethitHeroUID(HIT_BY_EWEAPON,(hit2+1));
6742
1/2
✓ Branch 0 taken 2890 times.
✗ Branch 1 not taken.
2890 if (get_bit(quest_rules, qr_BROKENHITBY))
6743 {
6744 2890 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getUID());
6745 2890 }
6746 else
6747 {
6748
6749 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getScriptUID());
6750 }
6751 2890 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID,ewpnspr->getUID());
6752 2890 sethitHeroUID(HIT_BY_EWEAPON_TYPE, ewpnspr->id);
6753 2890 }
6754
6755 2890 hitdir = hdir;
6756 2890 ewpnspr->onhit(false);
6757
6758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if (IsSideSwim())
6759 {
6760 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6761 }
6762
3/4
✓ Branch 0 taken 2861 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2861 times.
2890 else if(action==swimming || hopclk==0xFF)
6763 {
6764 29 action=swimhit; FFCore.setHeroAction(swimhit);
6765 29 }
6766 else
6767 {
6768 2861 action=gothit; FFCore.setHeroAction(gothit);
6769 }
6770
6771 2890 hclk=iframes;
6772
6773
7/8
✓ Branch 0 taken 2887 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2887 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1006 times.
✓ Branch 5 taken 1881 times.
✓ Branch 6 taken 53 times.
✓ Branch 7 taken 953 times.
2890 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6774 {
6775 1937 spins = charging = attackclk = 0;
6776 1937 attack=none;
6777 1937 tapping = false;
6778 1937 }
6779
6780 2890 sfx(getHurtSFX(),pan(x.getInt()));
6781 2890 return;
6782 }
6783
6784 // The rest of this method deals with damage combos, which can be jumped over.
6785
4/4
✓ Branch 0 taken 5746284 times.
✓ Branch 1 taken 3268 times.
✓ Branch 2 taken 5746284 times.
✓ Branch 3 taken 3268 times.
5749552 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
6786
6787 5746284 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
6788 5746284 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
6789
2/2
✓ Branch 0 taken 47666 times.
✓ Branch 1 taken 5698618 times.
5746284 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
6790
2/2
✓ Branch 0 taken 47666 times.
✓ Branch 1 taken 5698618 times.
5746284 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
6791
6792
2/2
✓ Branch 0 taken 5746284 times.
✓ Branch 1 taken 9658640 times.
15404924 for(int32_t i=get_bit(quest_rules, qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
6793 9658640 (void)checkdamagecombos(dx1,dx2,dy1,dy2,i);
6794 6418559 }
6795
6796 3582 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
6797 {
6798 3582 return checkdamagecombos(dx,dx,dy,dy);
6799 }
6800
6801 114 void HeroClass::doHit(int32_t hdir)
6802 {
6803 114 hitdir = hdir;
6804
6805
3/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 114 times.
114 if (action != rafting && action != freeze && action != sideswimfreeze)
6806 {
6807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (IsSideSwim())
6808 {
6809 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6810 }
6811
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 else if (action == swimming || hopclk == 0xFF)
6812 {
6813 action=swimhit; FFCore.setHeroAction(swimhit);
6814 }
6815 else
6816 {
6817 114 action=gothit; FFCore.setHeroAction(gothit);
6818 }
6819 114 }
6820
6821 114 hclk=48;
6822
6823
5/8
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 39 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 75 times.
114 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6824 {
6825 39 spins = charging = attackclk = 0;
6826 39 attack=none;
6827 39 tapping = false;
6828 39 }
6829
6830 114 sfx(getHurtSFX(),pan(x.getInt()));
6831 114 }
6832
6833 10553262 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
6834 {
6835
5/6
✓ Branch 0 taken 10553249 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 10548363 times.
✓ Branch 3 taken 4886 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10548363 times.
10553262 if(hclk || superman || fallclk)
6836 4899 return false;
6837
6838 10548363 int32_t hp_mod[4] = {0};
6839 int32_t cid[8];
6840 10548363 byte hasKB = 0;
6841
6842 {
6843
2/2
✓ Branch 0 taken 4503053 times.
✓ Branch 1 taken 6045310 times.
10548363 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
6844 10548363 newcombo& cmb = combobuf[cid[0]];
6845
4/4
✓ Branch 0 taken 10548360 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10548216 times.
✓ Branch 3 taken 144 times.
10548363 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6846 {
6847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(cmb.usrflags&cflag1)
6848 hp_mod[0] = cmb.attributes[0] / -10000L;
6849 else
6850 144 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!(cmb.usrflags&cflag2))
6852 144 hasKB |= 1<<0;
6853 144 }
6854 }
6855 {
6856
2/2
✓ Branch 0 taken 4503053 times.
✓ Branch 1 taken 6045310 times.
10548363 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
6857 10548363 newcombo& cmb = combobuf[cid[1]];
6858
4/4
✓ Branch 0 taken 10548360 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10548199 times.
✓ Branch 3 taken 161 times.
10548363 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6859 {
6860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
161 if(cmb.usrflags&cflag1)
6861 hp_mod[1] = cmb.attributes[0] / -10000L;
6862 else
6863 161 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
161 if(!(cmb.usrflags&cflag2))
6865 161 hasKB |= 1<<1;
6866 161 }
6867 }
6868 {
6869
2/2
✓ Branch 0 taken 4503053 times.
✓ Branch 1 taken 6045310 times.
10548363 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
6870 10548363 newcombo& cmb = combobuf[cid[2]];
6871
4/4
✓ Branch 0 taken 10548360 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10548225 times.
✓ Branch 3 taken 135 times.
10548363 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6872 {
6873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if(cmb.usrflags&cflag1)
6874 hp_mod[2] = cmb.attributes[0] / -10000L;
6875 else
6876 135 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if(!(cmb.usrflags&cflag2))
6878 135 hasKB |= 1<<2;
6879 135 }
6880 }
6881 {
6882
2/2
✓ Branch 0 taken 4503053 times.
✓ Branch 1 taken 6045310 times.
10548363 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
6883 10548363 newcombo& cmb = combobuf[cid[3]];
6884
4/4
✓ Branch 0 taken 10548360 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 10548210 times.
✓ Branch 3 taken 150 times.
10548363 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6885 {
6886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(cmb.usrflags&cflag1)
6887 hp_mod[3] = cmb.attributes[0] / -10000L;
6888 else
6889 150 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(!(cmb.usrflags&cflag2))
6891 150 hasKB |= 1<<3;
6892 150 }
6893 }
6894
6895 10548363 int32_t bestcid=0;
6896 10548363 int32_t hp_modtotal=0;
6897
2/2
✓ Branch 0 taken 7669081 times.
✓ Branch 1 taken 2879282 times.
10548363 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6898
2/2
✓ Branch 0 taken 7664086 times.
✓ Branch 1 taken 2884277 times.
10548363 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6899
2/2
✓ Branch 0 taken 7669113 times.
✓ Branch 1 taken 2879250 times.
10548363 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6900
2/2
✓ Branch 0 taken 7664119 times.
✓ Branch 1 taken 2884244 times.
10548363 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6901
6902
2/2
✓ Branch 0 taken 21096726 times.
✓ Branch 1 taken 10548363 times.
31645089 for (int32_t i = 0; i <= 1; ++i)
6903 {
6904
2/2
✓ Branch 0 taken 15690258 times.
✓ Branch 1 taken 5406468 times.
21096726 if(tmpscr2[i].valid!=0)
6905 {
6906
2/2
✓ Branch 0 taken 5024615 times.
✓ Branch 1 taken 381853 times.
5406468 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
6907 {
6908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6910
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6912 5024615 }
6913 else
6914 {
6915
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6916
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6917
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6918
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6919 }
6920 5406468 }
6921 21096726 }
6922
6923
2/2
✓ Branch 0 taken 42193452 times.
✓ Branch 1 taken 10548363 times.
52741815 for(int32_t i=0; i<4; i++)
6924 {
6925
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 26669060 times.
42193452 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
6926 {
6927
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
6928 {
6929
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotal)
6930 {
6931 63 hp_modtotal = hp_mod[i];
6932 63 bestcid = cid[i];
6933 63 }
6934 15524232 }
6935
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
6936 {
6937
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotal)
6938 {
6939 hp_modtotal = hp_mod[i];
6940 bestcid = cid[i];
6941 }
6942 139 }
6943 15524392 }
6944
2/2
✓ Branch 0 taken 26668943 times.
✓ Branch 1 taken 117 times.
26669060 else if(hp_mod[i] < hp_modtotal)
6945 {
6946 117 hp_modtotal = hp_mod[i];
6947 117 bestcid = cid[i];
6948 117 }
6949 42193452 }
6950
6951 {
6952 10548363 cid[4] = MAPFFCOMBO(dx1,dy1);
6953 10548363 newcombo& cmb = combobuf[cid[4]];
6954
4/4
✓ Branch 0 taken 10548168 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 10547281 times.
✓ Branch 3 taken 887 times.
10548363 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6955 {
6956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 887 times.
887 if(cmb.usrflags&cflag1 )
6957 hp_mod[0] = cmb.attributes[0]/10000L;
6958 else
6959 887 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6960
1/2
✓ Branch 0 taken 887 times.
✗ Branch 1 not taken.
887 if(!(cmb.usrflags&cflag2))
6961 hasKB |= 1<<4;
6962 887 }
6963 }
6964 {
6965 10548363 cid[5] = MAPFFCOMBO(dx1,dy2);
6966 10548363 newcombo& cmb = combobuf[cid[5]];
6967
4/4
✓ Branch 0 taken 10548159 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 10547269 times.
✓ Branch 3 taken 890 times.
10548363 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6968 {
6969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 890 times.
890 if(cmb.usrflags&cflag1 )
6970 hp_mod[1] = cmb.attributes[0]/10000L;
6971 else
6972 890 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6973
1/2
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
890 if(!(cmb.usrflags&cflag2))
6974 hasKB |= 1<<5;
6975 890 }
6976 }
6977 {
6978 10548363 cid[6] = MAPFFCOMBO(dx2,dy1);
6979 10548363 newcombo& cmb = combobuf[cid[6]];
6980
4/4
✓ Branch 0 taken 10548171 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 10547286 times.
✓ Branch 3 taken 885 times.
10548363 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6981 {
6982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 885 times.
885 if(cmb.usrflags&cflag1 )
6983 hp_mod[2] = cmb.attributes[0]/10000L;
6984 else
6985 885 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6986
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 if(!(cmb.usrflags&cflag2))
6987 hasKB |= 1<<6;
6988 885 }
6989 }
6990 {
6991 10548363 cid[7] = MAPFFCOMBO(dx2,dy2);
6992 10548363 newcombo& cmb = combobuf[cid[7]];
6993
4/4
✓ Branch 0 taken 10548162 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 10547274 times.
✓ Branch 3 taken 888 times.
10548363 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6994 {
6995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 888 times.
888 if(cmb.usrflags&cflag1 )
6996 hp_mod[3] = cmb.attributes[0]/10000L;
6997 else
6998 888 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6999
1/2
✓ Branch 0 taken 888 times.
✗ Branch 1 not taken.
888 if(!(cmb.usrflags&cflag2))
7000 hasKB |= 1<<7;
7001 888 }
7002 }
7003
7004 10548363 int32_t bestffccid = 0;
7005 10548363 int32_t hp_modtotalffc = 0;
7006
7007
2/2
✓ Branch 0 taken 21096726 times.
✓ Branch 1 taken 10548363 times.
31645089 for (int32_t i = 0; i <= 1; ++i)
7008 {
7009
2/2
✓ Branch 0 taken 15690258 times.
✓ Branch 1 taken 5406468 times.
21096726 if(tmpscr2[i].valid!=0)
7010 {
7011
2/2
✓ Branch 0 taken 5024615 times.
✓ Branch 1 taken 381853 times.
5406468 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
7012 {
7013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7014
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5024615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5024615 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7017 5024615 }
7018 else
7019 {
7020
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7021
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7022
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7023
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 381502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
381853 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7024 }
7025 5406468 }
7026 21096726 }
7027
7028
2/2
✓ Branch 0 taken 42193452 times.
✓ Branch 1 taken 10548363 times.
52741815 for(int32_t i=0; i<4; i++)
7029 {
7030
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 26669060 times.
42193452 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7031 {
7032
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotalffc >= 0)
7033 {
7034
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotalffc)
7035 {
7036 63 hp_modtotalffc = hp_mod[i];
7037 63 bestffccid = cid[4+i];
7038 63 }
7039 15524232 }
7040
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0)
7041 {
7042
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotalffc)
7043 {
7044 hp_modtotalffc = hp_mod[i];
7045 bestffccid = cid[4+i];
7046 }
7047 139 }
7048 15524392 }
7049
2/2
✓ Branch 0 taken 26668053 times.
✓ Branch 1 taken 1007 times.
26669060 else if(hp_mod[i] < hp_modtotalffc)
7050 {
7051 1007 hp_modtotalffc = hp_mod[i];
7052 1007 bestffccid = cid[4+i];
7053 1007 }
7054 42193452 }
7055
7056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10548363 times.
10548363 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7057
1/2
✓ Branch 0 taken 10548363 times.
✗ Branch 1 not taken.
10548363 if(hp_modtotalffc < hp_modmin) bestcid = bestffccid;
7058
7059 10548363 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7060 10548363 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7061 10548363 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7062
1/2
✓ Branch 0 taken 10548363 times.
✗ Branch 1 not taken.
10548363 if(current_ring)
7063 {
7064 global_defring = !global_defring;
7065 global_perilring = !global_perilring;
7066 }
7067 10548363 int32_t itemid = current_item_id(itype_boots);
7068
7069
2/2
✓ Branch 0 taken 10090474 times.
✓ Branch 1 taken 457889 times.
10548363 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7070
2/2
✓ Branch 0 taken 10090474 times.
✓ Branch 1 taken 457889 times.
10548363 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7071
7072
2/2
✓ Branch 0 taken 10547293 times.
✓ Branch 1 taken 1070 times.
10548363 if(hp_modmin<0)
7073 {
7074
8/14
✓ Branch 0 taken 945 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 945 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 945 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 945 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 945 times.
✓ Branch 10 taken 945 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 945 times.
1070 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7075 {
7076
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 14 times.
125 if (!do_health_check) return true;
7077 111 std::vector<int32_t> &ev = FFCore.eventData;
7078 111 ev.clear();
7079 111 ev.push_back(-hp_modmin*10000);
7080
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 6 times.
111 ev.push_back((hasKB ? dir^1 : -1)*10000);
7081 111 ev.push_back(0);
7082 111 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7083 111 ev.push_back(48*10000);
7084 111 ev.push_back(ZSD_COMBODATA*10000);
7085 111 ev.push_back(bestcid);
7086
7087 111 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7088 111 int32_t dmg = ev[0]/10000;
7089 111 bool nullhit = ev[2] != 0;
7090
7091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(nullhit) {ev.clear(); return false;}
7092
7093 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7094 111 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7095
7096 111 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7097 111 dmg = ev[0]/10000;
7098 111 int32_t hdir = ev[1]/10000;
7099 111 nullhit = ev[2] != 0;
7100 111 bool divineprot = ev[3] != 0;
7101 111 int32_t iframes = ev[4] / 10000;
7102 111 ev.clear();
7103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(nullhit) return false;
7104
7105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!divineprot)
7106 {
7107
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 3 times.
111 game->set_life(zc_max(game->get_life()-dmg,0));
7108 111 }
7109
7110 111 hitdir = hdir;
7111 111 doHit(hitdir);
7112 111 hclk = iframes;
7113 111 return true;
7114 }
7115
2/2
✓ Branch 0 taken 876 times.
✓ Branch 1 taken 69 times.
945 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7116 945 }
7117
7118 10548238 return false;
7119 10553262 }
7120
7121 13863 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7122 {
7123
1/2
✓ Branch 0 taken 13863 times.
✗ Branch 1 not taken.
13863 if(force_hdir > 3) force_hdir = -1;
7124 13863 enemy* enemyptr = (enemy*)guys.spr(hit2);
7125
1/2
✓ Branch 0 taken 13863 times.
✗ Branch 1 not taken.
13863 if(!enemyptr) return 0;
7126 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7127 13863 int32_t stompid = current_item_id(itype_stompboots);
7128
5/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13848 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
13863 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7129
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7131 {
7132 paymagiccost(stompid);
7133 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7134
7135 if(itemsbuf[stompid].flags & ITEM_FLAG1)
7136 {
7137 fall = -(itemsbuf[stompid].misc1);
7138 }
7139
7140 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7141 game->set_item(stompid,false);
7142
7143 // Stomp Boots script
7144 if(itemsbuf[stompid].script != 0 && !(item_doscript[stompid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
7145 {
7146 //clear the item script stack for a new script
7147 ri = &(itemScriptData[stompid]);
7148 for ( int32_t q = 0; q < 1024; q++ ) item_stack[stompid][q] = 0xFFFF;
7149 ri->Clear();
7150 //itemScriptData[(stompid & 0xFFF)].Clear();
7151 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(stompid & 0xFFF)][q] = 0;
7152 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid & 0xFFF);
7153 item_doscript[stompid] = 1;
7154 itemscriptInitialised[stompid] = 0;
7155 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid);
7156 }
7157
7158 return -1;
7159 }
7160
5/6
✓ Branch 0 taken 10104 times.
✓ Branch 1 taken 3759 times.
✓ Branch 2 taken 9665 times.
✓ Branch 3 taken 439 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9665 times.
13863 else if(superman || !(scriptcoldet&1) || fallclk)
7161 4198 return 0;
7162 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7163 //!Add a flag check to this if:
7164
5/6
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 5633 times.
✓ Branch 2 taken 4032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1830 times.
✓ Branch 5 taken 2202 times.
9665 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7165
3/4
✓ Branch 0 taken 1587 times.
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3789 times.
4032 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7166 {
7167 5876 return -1;
7168 }
7169
7170 3789 std::vector<int32_t> &ev = FFCore.eventData;
7171 3789 ev.clear();
7172 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7173 3789 ev.push_back((enemy_dp(hit2) *10000));
7174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3789 times.
3789 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7175 3789 ev.push_back(0);
7176 3789 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7177 3789 ev.push_back(48*10000);
7178 3789 ev.push_back(ZSD_NPC*10000);
7179 3789 ev.push_back(enemyptr->getUID());
7180
7181 3789 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7182 3789 int32_t dmg = ev[0] / 10000;
7183 3789 bool nullhit = ev[2] != 0;
7184
7185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3789 times.
3789 if(nullhit) {ev.clear(); return -1;}
7186
7187 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7188 3789 ev[0] = ((ringpower(dmg)*10000));
7189
7190 3789 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7191 3789 dmg = ev[0] / 10000;
7192 3789 int32_t hdir = ev[1] / 10000;
7193 3789 nullhit = ev[2] != 0;
7194 3789 bool divineprot = ev[3] != 0;
7195 3789 int32_t iframes = ev[4] / 10000;
7196 3789 ev.clear();
7197
7198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3789 times.
3789 if(nullhit) return -1;
7199
7200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3789 times.
3789 if(!divineprot)
7201 {
7202
2/2
✓ Branch 0 taken 3765 times.
✓ Branch 1 taken 24 times.
3789 game->set_life(zc_max(game->get_life()-dmg,0));
7203 3789 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7204 3789 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7205
1/2
✓ Branch 0 taken 3789 times.
✗ Branch 1 not taken.
3789 if (get_bit(quest_rules, qr_BROKENHITBY))
7206 {
7207 3789 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7208 3789 }
7209 else
7210 {
7211 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->script_UID);
7212 }
7213 3789 sethitHeroUID(HIT_BY_NPC_ENGINE_UID,enemyptr->getUID());
7214 3789 sethitHeroUID(HIT_BY_NPC_ID, enemyptr->id);
7215 3789 sethitHeroUID(HIT_BY_NPC_TYPE, enemyptr->family);
7216 3789 }
7217
7218 3789 hitdir = hdir;
7219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3789 times.
3789 if (IsSideSwim())
7220 {
7221 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7222 }
7223
3/4
✓ Branch 0 taken 3757 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3757 times.
3789 else if(action==swimming || hopclk==0xFF)
7224 {
7225 32 action=swimhit; FFCore.setHeroAction(swimhit);
7226 32 }
7227 else
7228 {
7229 3757 action=gothit; FFCore.setHeroAction(gothit);
7230 }
7231
7232 3789 hclk=iframes;
7233 3789 sfx(getHurtSFX(),pan(x.getInt()));
7234
7235
7/8
✓ Branch 0 taken 3787 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1557 times.
✓ Branch 5 taken 2230 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1509 times.
3789 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7236 {
7237 2280 spins = charging = attackclk = 0;
7238 2280 attack=none;
7239 2280 tapping = false;
7240 2280 }
7241
7242 3789 enemy_scored(hit2);
7243 3789 int32_t dm7 = enemyptr->dmisc7;
7244 3789 int32_t dm8 = enemyptr->dmisc8;
7245
7246
3/3
✓ Branch 0 taken 1737 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2049 times.
3789 switch(enemyptr->family)
7247 {
7248 case eeWALLM:
7249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(enemyptr->hp>0)
7250 {
7251 3 GrabHero(hit2);
7252 3 inwallm=true;
7253 3 action=none; FFCore.setHeroAction(none);
7254 3 }
7255 3 break;
7256
7257 //case eBUBBLEST:
7258 //case eeBUBBLE:
7259 case eeWALK:
7260 {
7261 2049 int32_t itemid = current_item_id(itype_whispring);
7262 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7263
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1889 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
2049 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7264
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1889 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
2049 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7265
7266
5/7
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 79 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
2049 switch(dm7)
7267 {
7268 case e7tTEMPJINX:
7269
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 258 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
277 if(dm8==0 || dm8==2)
7270
4/4
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 254 times.
512 if(swordclk>=0 && !(sworddivisor==0))
7271 254 swordclk=150;
7272
7273
3/4
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 258 times.
277 if(dm8==1 || dm8==2)
7274
3/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 18 times.
37 if(itemclk>=0 && !(itemdivisor==0))
7275 18 itemclk=150;
7276
7277 277 break;
7278
7279 case e7tPERMJINX:
7280
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
54 if(dm8==0 || dm8==2)
7281
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
38 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7282
7283
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
54 if(dm8==1 || dm8==2)
7284
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
16 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7285
7286 54 break;
7287
7288 case e7tUNJINX:
7289
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
79 if(dm8==0 || dm8==2)
7290 67 swordclk=0;
7291
7292
3/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
79 if(dm8==1 || dm8==2)
7293 12 itemclk=0;
7294
7295 79 break;
7296
7297 case e7tTAKEMAGIC:
7298 game->change_dmagic(-dm8*game->get_magicdrainrate());
7299 break;
7300
7301 case e7tTAKERUPEES:
7302 21 game->change_drupy(-dm8);
7303 21 break;
7304
7305 case e7tDRUNK:
7306 drunkclk += dm8;
7307 break;
7308 }
7309 2049 verifyAWpn();
7310
2/2
✓ Branch 0 taken 1998 times.
✓ Branch 1 taken 51 times.
2049 if(dm7 >= e7tEATITEMS)
7311 {
7312 51 EatHero(hit2);
7313 51 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7314 51 action=none; FFCore.setHeroAction(none);
7315 51 }
7316 }
7317 2049 }
7318 3789 return 0;
7319 13863 }
7320
7321 314009 void HeroClass::addsparkle(int32_t wpn)
7322 {
7323 //return;
7324 314009 weapon *w = (weapon*)Lwpns.spr(wpn);
7325 314009 int32_t itemid = w->parentitem;
7326
7327
2/2
✓ Branch 0 taken 310655 times.
✓ Branch 1 taken 3354 times.
314009 if(itemid<0)
7328 3354 return;
7329
7330 310655 int32_t itemtype = itemsbuf[itemid].family;
7331
7332
4/4
✓ Branch 0 taken 310582 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 77634 times.
✓ Branch 3 taken 232948 times.
310655 if(itemtype!=itype_cbyrna && frame%4)
7333 232948 return;
7334
7335
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 77634 times.
77707 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7336
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 77634 times.
77707 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7337 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7338
5/8
✓ Branch 0 taken 22591 times.
✓ Branch 1 taken 55116 times.
✓ Branch 2 taken 38407 times.
✓ Branch 3 taken 16709 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22591 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
77707 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7339 77707 int32_t direction=w->dir;
7340
7341
2/2
✓ Branch 0 taken 38407 times.
✓ Branch 1 taken 39300 times.
77707 if(sparkle_type)
7342 {
7343 39300 int32_t h=0;
7344 39300 int32_t v=0;
7345
7346
6/6
✓ Branch 0 taken 31465 times.
✓ Branch 1 taken 7835 times.
✓ Branch 2 taken 28007 times.
✓ Branch 3 taken 3458 times.
✓ Branch 4 taken 6095 times.
✓ Branch 5 taken 21912 times.
39300 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7347 {
7348 17388 h=-1;
7349 17388 }
7350
7351
6/6
✓ Branch 0 taken 31738 times.
✓ Branch 1 taken 7562 times.
✓ Branch 2 taken 26489 times.
✓ Branch 3 taken 5249 times.
✓ Branch 4 taken 3934 times.
✓ Branch 5 taken 22555 times.
39300 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7352 {
7353 16745 h=1;
7354 16745 }
7355
7356
6/6
✓ Branch 0 taken 37062 times.
✓ Branch 1 taken 2238 times.
✓ Branch 2 taken 33128 times.
✓ Branch 3 taken 3934 times.
✓ Branch 4 taken 6095 times.
✓ Branch 5 taken 27033 times.
39300 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7357 {
7358 12267 v=-1;
7359 12267 }
7360
7361
6/6
✓ Branch 0 taken 36371 times.
✓ Branch 1 taken 2929 times.
✓ Branch 2 taken 31122 times.
✓ Branch 3 taken 5249 times.
✓ Branch 4 taken 3458 times.
✓ Branch 5 taken 27664 times.
39300 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7362 {
7363 11636 v=1;
7364 11636 }
7365
7366 // Damaging boomerang sparkle?
7367
3/4
✓ Branch 0 taken 16709 times.
✓ Branch 1 taken 22591 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16709 times.
39300 if(wpn3 && itemtype==itype_brang)
7368 {
7369 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7370 // whatever it just bounced off of if it's shielded from that direction.
7371
6/6
✓ Branch 0 taken 10964 times.
✓ Branch 1 taken 5745 times.
✓ Branch 2 taken 10517 times.
✓ Branch 3 taken 447 times.
✓ Branch 4 taken 4476 times.
✓ Branch 5 taken 6041 times.
16709 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7372 6041 direction=oppositeDir[direction];
7373 16709 }
7374
4/4
✓ Branch 0 taken 38355 times.
✓ Branch 1 taken 945 times.
✓ Branch 2 taken 17684 times.
✓ Branch 3 taken 20671 times.
39300 if(itemtype==itype_brang && get_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7375
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 39227 times.
39300 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7376
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 39227 times.
39300 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7377
5/10
✓ Branch 0 taken 39300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39300 times.
✗ Branch 9 not taken.
39300 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7378 39300 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7379 39300 }
7380 314009 }
7381
7382 // For wPhantoms
7383 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7384 {
7385 if(frame%4) return;
7386
7387 int32_t arrow = -1;
7388
7389 for(int32_t i=0; i<Lwpns.Count(); i++)
7390 {
7391 weapon *w = (weapon*)Lwpns.spr(i);
7392
7393 if(w->id == wPhantom && w->type == type1)
7394 {
7395 arrow = i;
7396 break;
7397 }
7398 }
7399
7400 if(arrow==-1)
7401 {
7402 return;
7403 }
7404
7405 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7406 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7407 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7408 }
7409
7410 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7411 6418199 void HeroClass::PhantomsCleanup()
7412 {
7413
1/2
✓ Branch 0 taken 6418199 times.
✗ Branch 1 not taken.
6418199 if(Lwpns.idCount(wPhantom))
7414 {
7415 for(int32_t i=0; i<Lwpns.Count(); i++)
7416 {
7417 weapon *w = ((weapon *)Lwpns.spr(i));
7418 if ( w->id == wPhantom && !w->isScriptGenerated() )
7419 {
7420 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7421 {
7422 Lwpns.remove(w);
7423 }
7424 }
7425 }
7426 }
7427 6418199 }
7428
7429 //Waitframe handler for refilling operations
7430 4932 static void do_refill_waitframe()
7431 {
7432 4932 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7433
1/2
✓ Branch 0 taken 4932 times.
✗ Branch 1 not taken.
4932 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7434 {
7435 script_drawing_commands.Clear();
7436 if(DMaps[currdmap].passive_sub_script != 0)
7437 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7438 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
7439 {
7440 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7441 passive_subscreen_waitdraw = false;
7442 }
7443 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7444 }
7445 4932 advanceframe(true);
7446 4932 }
7447 //Special handler if it's a "fairy revive"
7448 static void do_death_refill_waitframe()
7449 {
7450 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7451 //This script should be able to draw a 'fairy saving the player' animation -Em
7452 do_refill_waitframe();
7453 }
7454
7455 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7456 {
7457 int32_t found_unowned = -1;
7458 for(int q = 0; q < MAXITEMS; ++q)
7459 {
7460 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7461 {
7462 if(game->get_item(q))
7463 return q;
7464 if(unowned)
7465 found_unowned = q;
7466 }
7467 }
7468 return found_unowned;
7469 }
7470
7471 int32_t getPushDir(int32_t flag)
7472 {
7473 switch(flag)
7474 {
7475 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7476 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7477 case mfPUSHUINS:
7478 return up;
7479 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7480 return down;
7481 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7482 case mfPUSHLRINS: case mfPUSHLINS:
7483 return left;
7484 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7485 return right;
7486 }
7487 return -1;
7488 }
7489
7490 void post_item_collect();
7491
7492 6418560 bool HeroClass::handle_portal_collide(portal* p)
7493 {
7494
1/2
✓ Branch 0 taken 6418560 times.
✗ Branch 1 not taken.
6418560 if(!p) return false;
7495 6418560 p->animate(0);
7496
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6418560 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6418560 if(p->destdmap < 0 || p->destdmap >= MAXDMAPS)
7497 6418560 return false;
7498 if(abs(x - p->x) < 12
7499 && abs(y - p->y) < 12)
7500 {
7501 if(p->prox_active)
7502 {
7503 //Store some values to restore if 'warp fails'
7504 int32_t tLastEntrance = lastentrance,
7505 tLastEntranceDMap = lastentrance_dmap,
7506 tContScr = game->get_continue_scrn(),
7507 tContDMap = game->get_continue_dmap();
7508 int32_t sourcescr = currscr, sourcedmap = currdmap;
7509 zfix tx = x, ty = y, tz = z;
7510 x = p->x;
7511 y = p->y;
7512
7513 int32_t weff = p->weffect,
7514 wsfx = p->wsfx;
7515
7516 int32_t savep = p->saved_data;
7517 //After this line, 'p' becomes INVALID!
7518 FFCore.warp_player(wtIWARP, p->destdmap, p->destscr,
7519 -1, -1, weff, wsfx, 0, -1);
7520
7521 if(mirrorBonk()) //Invalid landing, warp back!
7522 {
7523 action = none; FFCore.setHeroAction(none);
7524 lastentrance = tLastEntrance;
7525 lastentrance_dmap = tLastEntranceDMap;
7526 game->set_continue_scrn(tContScr);
7527 game->set_continue_dmap(tContDMap);
7528 x = tx;
7529 y = ty;
7530 z = tz;
7531 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7532 wsfx, 0, -1);
7533 handle_portal_prox(&mirror_portal);
7534 portals.forEach([&](sprite& p)
7535 {
7536 handle_portal_prox((portal*)&p);
7537 return false;
7538 });
7539 }
7540 else game->clear_portal(savep); //Remove portal once used
7541 return true;
7542 }
7543 }
7544 else p->prox_active = true;
7545 return false;
7546 6418560 }
7547 13 void HeroClass::handle_portal_prox(portal* p)
7548 {
7549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p) return;
7550
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3 times.
13 p->prox_active = !(abs(x - p->x) < 12 && abs(y - p->y) < 12);
7551 13 }
7552 // returns true when game over
7553 18711005 bool HeroClass::animate(int32_t)
7554 {
7555 18711005 int32_t lsave=0;
7556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18711005 times.
18711005 if(immortal > 0)
7557 --immortal;
7558 18711005 prompt_combo = 0;
7559
2/2
✓ Branch 0 taken 12292445 times.
✓ Branch 1 taken 6418560 times.
18711005 if (onpassivedmg)
7560 {
7561 12292445 onpassivedmg=false;
7562 12292445 }
7563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6418560 times.
6418560 else if (damageovertimeclk)
7564 {
7565 damageovertimeclk = 0;
7566 }
7567
7568
2/2
✓ Branch 0 taken 18710571 times.
✓ Branch 1 taken 434 times.
18711005 if(lift_wpn)
7569 {
7570 434 auto oldid = lift_wpn->id;
7571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 switch(lift_wpn->id)
7572 {
7573 case wLitBomb:
7574 case wBomb:
7575 case wLitSBomb:
7576 case wSBomb:
7577 if(lift_wpn->misc && get_bit(quest_rules,qr_HELD_BOMBS_EXPLODE)) //timed fuse
7578 {
7579 lift_wpn->limited_animate();
7580 if(lift_wpn->id != oldid)
7581 {
7582 lift_wpn->moveflags &= ~FLAG_OBEYS_GRAV;
7583 drop_liftwpn();
7584 goto heroanimate_skip_liftwpn;
7585 }
7586 ++lift_wpn->clk;
7587 }
7588 break;
7589 }
7590
1/2
✓ Branch 0 taken 434 times.
✗ Branch 1 not taken.
434 if(lift_wpn->dead>0)
7591 --lift_wpn->dead;
7592
7593
1/2
✓ Branch 0 taken 434 times.
✗ Branch 1 not taken.
434 if(lift_wpn->dead==0)
7594 {
7595 if(lift_wpn->death_spawnitem > -1)
7596 {
7597 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, lift_wpn->death_spawnitem, lift_wpn->death_item_pflags, 0));
7598 itm->fakez = lift_wpn->fakez;
7599 items.add(itm);
7600 }
7601 if(lift_wpn->death_spawndropset > -1)
7602 {
7603 auto itid = select_dropitem(lift_wpn->death_spawndropset);
7604 if(itid > -1)
7605 {
7606 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, itid, lift_wpn->death_item_pflags, 0));
7607 itm->fakez = lift_wpn->fakez;
7608 itm->from_dropset = lift_wpn->death_spawndropset;
7609 items.add(itm);
7610 }
7611 }
7612 switch(lift_wpn->death_sprite)
7613 {
7614 case -2: decorations.add(new dBushLeaves(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dBUSHLEAVES, 0, 0)); break;
7615 case -3: decorations.add(new dFlowerClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dFLOWERCLIPPINGS, 0, 0)); break;
7616 case -4: decorations.add(new dGrassClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dGRASSCLIPPINGS, 0, 0)); break;
7617 default:
7618 if(lift_wpn->death_sprite < 0) break;
7619 decorations.add(new comboSprite(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), 0, 0, lift_wpn->death_sprite));
7620 }
7621 if(lift_wpn->death_sfx > 0)
7622 sfx(lift_wpn->death_sfx, pan(int32_t(lift_wpn->x)));
7623 delete lift_wpn;
7624 lift_wpn = nullptr;
7625 }
7626 heroanimate_skip_liftwpn:;
7627 434 }
7628
7629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18711005 times.
18711005 if(cheats_execute_goto)
7630 {
7631 didpit=true;
7632 pitx=x;
7633 pity=y;
7634 dowarp(3,0);
7635 cheats_execute_goto=false;
7636 solid_update(false);
7637 return false;
7638 }
7639
7640
1/2
✓ Branch 0 taken 18711005 times.
✗ Branch 1 not taken.
18711005 if(cheats_execute_light)
7641 {
7642 naturaldark = !naturaldark;
7643 lighting(false, false, pal_litOVERRIDE);//Forcibly set permLit, overriding it's current setting
7644 cheats_execute_light = false;
7645 }
7646
7647
3/4
✓ Branch 0 taken 6418560 times.
✓ Branch 1 taken 12292445 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6418560 times.
18711005 if(action!=climbcovertop&&action!=climbcoverbottom)
7648 {
7649 6418560 climb_cover_x=-1000;
7650 6418560 climb_cover_y=-1000;
7651 6418560 }
7652
7653 18711005 handle_portal_collide(&mirror_portal);
7654
1/2
✓ Branch 0 taken 18711005 times.
✗ Branch 1 not taken.
18711005 portals.forEach([&](sprite& p)
7655 {
7656 return handle_portal_collide((portal*)&p);
7657 });
7658
7659
3/4
✓ Branch 0 taken 6415214 times.
✓ Branch 1 taken 12295791 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6415214 times.
18711005 if(z<=8&&fakez<=8)
7660 {
7661
2/2
✓ Branch 0 taken 42395 times.
✓ Branch 1 taken 6372819 times.
6415214 if (get_bit(quest_rules, qr_GRASS_SENSITIVE))
7662 {
7663 42395 bool g1 = isGrassType(COMBOTYPE(x+4,y+15)), g2 = isGrassType(COMBOTYPE(x+11,y+15)), g3 = isGrassType(COMBOTYPE(x+4,y+9)), g4 = isGrassType(COMBOTYPE(x+11,y+9));
7664
2/2
✓ Branch 0 taken 41531 times.
✓ Branch 1 taken 864 times.
42395 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7665 {
7666
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g1 = g1 || isGrassType(COMBOTYPEL(1,x+4,y+15)) || isGrassType(COMBOTYPEL(2,x+4,y+15));
7667
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g2 = g2 || isGrassType(COMBOTYPEL(1,x+11,y+15)) || isGrassType(COMBOTYPEL(2,x+11,y+15));
7668
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g3 = g3 || isGrassType(COMBOTYPEL(1,x+4,y+9)) || isGrassType(COMBOTYPEL(2,x+4,y+9));
7669
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g4 = g4 || isGrassType(COMBOTYPEL(1,x+11,y+9)) || isGrassType(COMBOTYPEL(2,x+11,y+9));
7670 864 }
7671
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42395 if(g1 && g2 && g3 && g4)
7672 {
7673 if(decorations.idCount(dTALLGRASS)==0)
7674 {
7675 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7676 }
7677 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+12)].attribytes[3];
7678 if (action==walking)
7679 sfx_no_repeat(thesfx,pan((int32_t)x));
7680 }
7681 42395 }
7682 else
7683 {
7684 6372819 bool g1 = isGrassType(COMBOTYPE(x,y+15)), g2 = isGrassType(COMBOTYPE(x+15,y+15));
7685
2/2
✓ Branch 0 taken 6345318 times.
✓ Branch 1 taken 27501 times.
6372819 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7686 {
7687
2/4
✓ Branch 0 taken 27501 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27501 times.
27501 g1 = g1 || isGrassType(COMBOTYPEL(1,x,y+15)) || isGrassType(COMBOTYPEL(2,x,y+15));
7688
2/4
✓ Branch 0 taken 27501 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27501 times.
27501 g2 = g2 || isGrassType(COMBOTYPEL(1,x+15,y+15)) || isGrassType(COMBOTYPEL(2,x+15,y+15));
7689 27501 }
7690
4/4
✓ Branch 0 taken 44398 times.
✓ Branch 1 taken 6328421 times.
✓ Branch 2 taken 5801 times.
✓ Branch 3 taken 38597 times.
6372819 if(g1 && g2)
7691 {
7692
2/2
✓ Branch 0 taken 38045 times.
✓ Branch 1 taken 552 times.
38597 if(decorations.idCount(dTALLGRASS)==0)
7693 {
7694
3/6
✓ Branch 0 taken 552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 552 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 552 times.
✗ Branch 5 not taken.
552 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7695 552 }
7696 38597 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+15)].attribytes[3];
7697
2/2
✓ Branch 0 taken 17055 times.
✓ Branch 1 taken 21542 times.
38597 if (action==walking )
7698 21542 sfx_no_repeat(thesfx,pan((int32_t)x));
7699 38597 }
7700 }
7701 6415214 }
7702
7703
2/2
✓ Branch 0 taken 12577866 times.
✓ Branch 1 taken 6133139 times.
18711005 if (get_bit(quest_rules, qr_SHALLOW_SENSITIVE))
7704 {
7705
19/26
✓ Branch 0 taken 281940 times.
✓ Branch 1 taken 12295926 times.
✓ Branch 2 taken 281940 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 280661 times.
✓ Branch 5 taken 1279 times.
✓ Branch 6 taken 280661 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 280021 times.
✓ Branch 9 taken 640 times.
✓ Branch 10 taken 280021 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 280021 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 280021 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 279811 times.
✓ Branch 17 taken 210 times.
✓ Branch 18 taken 279811 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 279778 times.
✓ Branch 21 taken 33 times.
✓ Branch 22 taken 279718 times.
✓ Branch 23 taken 60 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 279718 times.
12577866 if (z == 0 && fakez == 0 && action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7706 {
7707
2/2
✓ Branch 0 taken 256582 times.
✓ Branch 1 taken 23136 times.
304476 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
7708
2/2
✓ Branch 0 taken 24758 times.
✓ Branch 1 taken 254960 times.
279718 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
7709
2/2
✓ Branch 0 taken 23876 times.
✓ Branch 1 taken 882 times.
24758 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
7710
2/2
✓ Branch 0 taken 23170 times.
✓ Branch 1 taken 706 times.
23876 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
7711 {
7712
2/2
✓ Branch 0 taken 22979 times.
✓ Branch 1 taken 157 times.
23136 if(decorations.idCount(dRIPPLES)==0)
7713 {
7714
3/6
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 157 times.
✗ Branch 5 not taken.
157 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7715 157 }
7716 23136 int32_t watercheck = iswaterex(FFORCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, false, false, true, true);
7717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23136 times.
23136 if (combobuf[watercheck].usrflags&cflag2)
7718 {
7719 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7720 {
7721 onpassivedmg = true;
7722 if (!damageovertimeclk)
7723 {
7724 int32_t curhp = game->get_life();
7725 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7726 else game->set_life(vbound(game->get_life()+combobuf[watercheck].attributes[1]/10000L, 0, game->get_maxlife()));
7727 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7728 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
7729 {
7730 hclk = 48;
7731 hitdir = -1;
7732 action = gothit; FFCore.setHeroAction(gothit);
7733 }
7734 }
7735 if (combobuf[watercheck].attribytes[1] > 0)
7736 {
7737 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7738 else --damageovertimeclk;
7739 }
7740 else damageovertimeclk = 0;
7741 }
7742 else damageovertimeclk = 0;
7743 }
7744 23136 else damageovertimeclk = 0;
7745 23136 int32_t thesfx = combobuf[watercheck].attribytes[0];
7746
3/4
✓ Branch 0 taken 22806 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 22806 times.
✗ Branch 3 not taken.
23136 if (combobuf[watercheck].type != cSHALLOWWATER || !get_bit(quest_rules, qr_OLD_SHALLOW_SFX))
7747 {
7748 330 thesfx = combobuf[watercheck].attribytes[5];
7749 330 }
7750
2/2
✓ Branch 0 taken 12794 times.
✓ Branch 1 taken 10342 times.
23136 if (action==walking)
7751 10342 sfx_no_repeat(thesfx,pan((int32_t)x));
7752 23136 }
7753 279718 }
7754 12577866 }
7755 else
7756 {
7757
7/8
✓ Branch 0 taken 8860 times.
✓ Branch 1 taken 6124279 times.
✓ Branch 2 taken 8421 times.
✓ Branch 3 taken 439 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8421 times.
✓ Branch 6 taken 6124718 times.
✓ Branch 7 taken 8421 times.
6133139 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER) && z==0 && fakez==0)
7758 {
7759
2/2
✓ Branch 0 taken 8358 times.
✓ Branch 1 taken 63 times.
8421 if(decorations.idCount(dRIPPLES)==0)
7760 {
7761
3/6
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✗ Branch 5 not taken.
63 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7762 63 }
7763 8421 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
7764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8421 times.
8421 if (combobuf[watercheck].usrflags&cflag2)
7765 {
7766 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7767 {
7768 onpassivedmg = true;
7769 if (!damageovertimeclk)
7770 {
7771 int32_t curhp = game->get_life();
7772 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7773 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
7774 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7775 }
7776 if (combobuf[watercheck].attribytes[1] > 0)
7777 {
7778 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7779 else --damageovertimeclk;
7780 }
7781 else damageovertimeclk = 0;
7782 }
7783 else damageovertimeclk = 0;
7784 }
7785 8421 else damageovertimeclk = 0;
7786 8421 int32_t thesfx = combobuf[watercheck].attribytes[0];
7787
2/2
✓ Branch 0 taken 4914 times.
✓ Branch 1 taken 3507 times.
8421 if (action==walking )
7788 3507 sfx_no_repeat(thesfx,pan((int32_t)x));
7789 8421 }
7790 }
7791
7792
2/2
✓ Branch 0 taken 18710966 times.
✓ Branch 1 taken 39 times.
18711005 if(stomping)
7793 39 stomping = false;
7794
7795
2/2
✓ Branch 0 taken 18710686 times.
✓ Branch 1 taken 319 times.
18711005 if(getOnSideviewLadder())
7796 {
7797
4/8
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 319 times.
319 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
7798 {
7799 setOnSideviewLadder(false);
7800 }
7801
2/8
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
319 else if(CANFORCEFACEUP)
7802 {
7803 setDir(up);
7804 }
7805 319 }
7806
7807
6/8
✓ Branch 0 taken 6408860 times.
✓ Branch 1 taken 12302145 times.
✓ Branch 2 taken 6408220 times.
✓ Branch 3 taken 640 times.
✓ Branch 4 taken 6408220 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6408220 times.
18711005 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
7808 {
7809
2/2
✓ Branch 0 taken 6249947 times.
✓ Branch 1 taken 158273 times.
6408220 if(!get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
7810 {
7811 158273 checkchest(cCHEST);
7812 158273 checkchest(cLOCKEDCHEST);
7813 158273 checkchest(cBOSSCHEST);
7814 158273 }
7815
2/2
✓ Branch 0 taken 6379607 times.
✓ Branch 1 taken 28613 times.
6408220 if(!get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
7816 {
7817 28613 checkchest(cLOCKBLOCK);
7818 28613 checkchest(cBOSSLOCKBLOCK);
7819 28613 }
7820 6408220 }
7821 18711005 checksigns();
7822 18711005 checkgenpush();
7823
7824
4/4
✓ Branch 0 taken 6065839 times.
✓ Branch 1 taken 12645166 times.
✓ Branch 2 taken 2281 times.
✓ Branch 3 taken 6063558 times.
18711005 if(isStanding(true) && fall == 0)
7825 {
7826
1/2
✓ Branch 0 taken 6063558 times.
✗ Branch 1 not taken.
6063558 if(extra_jump_count > 0)
7827 extra_jump_count = 0;
7828 6063558 coyotetime = 0;
7829 6063558 }
7830
2/2
✓ Branch 0 taken 12295057 times.
✓ Branch 1 taken 352390 times.
12647447 else if(coyotetime < 65535)
7831 {
7832 352390 ++coyotetime;
7833 352390 }
7834
2/2
✓ Branch 0 taken 18700914 times.
✓ Branch 1 taken 10091 times.
18711005 if(can_use_item(itype_hoverboots,i_hoverboots))
7835 {
7836 10091 int32_t hoverid = current_item_id(itype_hoverboots);
7837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10091 times.
10091 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
7838 {
7839
1/2
✓ Branch 0 taken 10091 times.
✗ Branch 1 not taken.
10091 if(hoverclk < 0) hoverclk = 0;
7840 10091 hoverflags &= ~HOV_OUT;
7841 10091 }
7842 10091 }
7843 18711005 bool platformfell2 = false;
7844 18711005 int32_t gravity3 = (zinit.gravity2/100);
7845 18711005 int32_t termv = (zinit.terminalv);
7846 18711005 int32_t rocs = getRocsPressed();
7847
2/2
✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 18709883 times.
18711005 if (rocs != -1)
7848 {
7849 1122 itemdata const& itm = itemsbuf[rocs];
7850
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 if (itm.flags & ITEM_FLAG2)
7851 {
7852 if ((!(itm.flags & ITEM_FLAG3) || fall < 0) &&
7853 (!(itm.flags & ITEM_FLAG4) || fall > 0)) gravity3 = itm.misc3;
7854 }
7855
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 if (itm.flags & ITEM_FLAG5)
7856 {
7857 termv = itm.misc4;
7858 if (fall > termv) fall = termv;
7859 }
7860 1122 }
7861
2/2
✓ Branch 0 taken 261486 times.
✓ Branch 1 taken 18449519 times.
18711005 if(sideview_mode()) // Sideview gravity
7862 {
7863 //Handle falling through a platform
7864 261486 bool platformfell = false;
7865
4/4
✓ Branch 0 taken 133365 times.
✓ Branch 1 taken 128121 times.
✓ Branch 2 taken 133347 times.
✓ Branch 3 taken 18 times.
261486 if (on_sideview_solid_oldpos(x,y,old_x,old_y,true,3) && !on_sideview_solid_oldpos(x,y,old_x,old_y,false,3))
7866 {
7867
8/8
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 8 times.
18 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
7868 18 y+=1; //Fall down a pixel instantly, through the platform.
7869
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 10 times.
18 if(fall < 0) fall = 0;
7870
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 8 times.
18 if(jumping < 0) jumping = 0;
7871 18 platformfell2 = true;
7872 18 }
7873 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
7874
2/2
✓ Branch 0 taken 10790 times.
✓ Branch 1 taken 250696 times.
261486 if(!get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
7875 {
7876
14/22
✓ Branch 0 taken 9809 times.
✓ Branch 1 taken 981 times.
✓ Branch 2 taken 981 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 981 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 981 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 981 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 980 times.
✓ Branch 12 taken 980 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 980 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 980 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 980 times.
✓ Branch 20 taken 10789 times.
✓ Branch 21 taken 1 times.
11771 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
7877
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 980 times.
✓ Branch 2 taken 958 times.
✓ Branch 3 taken 22 times.
1002 || ((y+(fall/100)<=0) &&
7878 // Extra checks if Smart Screen Scrolling is enabled
7879
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7880 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
7881 {
7882 1 fall = jumping = 0; // Bumped his head
7883
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7884 y -= y.getInt()%8; //fix coords
7885 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7887 {
7888 1 checkdamagecombos(x+4, x+12, y-1, y-1);
7889 1 }
7890 1 }
7891 10790 }
7892 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
7893
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 261486 times.
✓ Branch 2 taken 261486 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 261486 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 261486 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 261486 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 261486 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 319 times.
✓ Branch 13 taken 261167 times.
261486 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
7894 {
7895
1/2
✓ Branch 0 taken 261167 times.
✗ Branch 1 not taken.
261167 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
7896 //zprint2("ydif is: %d\n", ydiff);
7897 //zprint2("ydif is: %d\n", (int32_t)fall);
7898 261167 falling_oldy = y; // Stomp Boots-related variable
7899
8/8
✓ Branch 0 taken 48363 times.
✓ Branch 1 taken 212804 times.
✓ Branch 2 taken 48299 times.
✓ Branch 3 taken 64 times.
✓ Branch 4 taken 48362 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 261166 times.
✓ Branch 7 taken 1 times.
261167 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
7900 {
7901 1 ydiff -= (y.getInt()+ydiff)%16;
7902 1 }
7903
4/4
✓ Branch 0 taken 68744 times.
✓ Branch 1 taken 192423 times.
✓ Branch 2 taken 66794 times.
✓ Branch 3 taken 1950 times.
261167 if(ydiff && !get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7904 {
7905
2/2
✓ Branch 0 taken 1097 times.
✓ Branch 1 taken 853 times.
1950 if(ydiff > 0)
7906 {
7907
2/2
✓ Branch 0 taken 1061 times.
✓ Branch 1 taken 2173 times.
3234 for(auto q = 0; q < ydiff; ++q)
7908 {
7909
2/2
✓ Branch 0 taken 2137 times.
✓ Branch 1 taken 36 times.
2173 if(on_sideview_solid_oldpos(x,y+q,old_x,old_y))
7910 {
7911 36 ydiff = q;
7912 36 break;
7913 }
7914 2137 }
7915 1097 }
7916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 853 times.
853 else if(ydiff < 0)
7917 {
7918
2/2
✓ Branch 0 taken 853 times.
✓ Branch 1 taken 1698 times.
2551 for(auto q = 0; q > ydiff; --q)
7919 {
7920
1/2
✓ Branch 0 taken 1698 times.
✗ Branch 1 not taken.
3396 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
7921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1698 times.
1698 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
7922 {
7923 ydiff = q;
7924 break;
7925 }
7926 1698 }
7927 853 }
7928 1950 }
7929 261167 y+=ydiff;
7930 261167 hs_starty+=ydiff;
7931
7932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 261167 times.
261167 for(int32_t j=0; j<chainlinks.Count(); j++)
7933 {
7934 chainlinks.spr(j)->y+=ydiff;
7935 }
7936
7937
1/2
✓ Branch 0 taken 261167 times.
✗ Branch 1 not taken.
261167 if(Lwpns.idFirst(wHookshot)>-1)
7938 {
7939 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
7940 }
7941
7942
1/2
✓ Branch 0 taken 261167 times.
✗ Branch 1 not taken.
261167 if(Lwpns.idFirst(wHSHandle)>-1)
7943 {
7944 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
7945 }
7946 261167 }
7947
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 319 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
319 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
7948 {
7949 fall = hoverclk = jumping = 0;
7950 inair = false;
7951 hoverflags = 0;
7952 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
7953 {
7954 WalkflagInfo info;
7955 if (game->get_watergrav()<0)
7956 {
7957 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
7958 execute(info);
7959 }
7960 else
7961 {
7962 info = walkflag(x,y+15+2,2,down);
7963 execute(info);
7964 }
7965 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
7966 }
7967 }
7968 // Stop hovering/falling if you land on something.
7969 261486 bool needFall = false;
7970
7/8
✓ Branch 0 taken 127634 times.
✓ Branch 1 taken 133852 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 261486 times.
✓ Branch 4 taken 134171 times.
✓ Branch 5 taken 127315 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 134158 times.
261486 if((on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
7971 {
7972 134158 stop_item_sfx(itype_hoverboots);
7973
1/2
✓ Branch 0 taken 124016 times.
✗ Branch 1 not taken.
258174 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE)
7974
2/2
✓ Branch 0 taken 126660 times.
✓ Branch 1 taken 7498 times.
134158 && !getOnSideviewLadder()
7975
3/4
✓ Branch 0 taken 126660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124016 times.
✓ Branch 3 taken 2644 times.
126660 && (fall > 0 || get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON)))
7976 126660 y-=(int32_t)y%8; //fix position
7977 134158 fall = hoverclk = jumping = 0;
7978 134158 inair = false;
7979 134158 hoverflags = 0;
7980
7981
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 134150 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
134158 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
7982 8 y = 160;
7983 134158 }
7984 // Stop hovering if you press down.
7985
3/6
✓ Branch 0 taken 127328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127328 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 127328 times.
✗ Branch 5 not taken.
127328 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
7986 {
7987 stop_item_sfx(itype_hoverboots);
7988 hoverclk = -hoverclk;
7989 reset_ladder();
7990 fall = gravity3;
7991 inair = false;
7992 }
7993
10/12
✓ Branch 0 taken 127328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3757 times.
✓ Branch 3 taken 123571 times.
✓ Branch 4 taken 1995 times.
✓ Branch 5 taken 1762 times.
✓ Branch 6 taken 1987 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 1987 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 281 times.
✓ Branch 11 taken 1706 times.
127328 else if (hoverclk < 1 && !inair && fall == 0 && !platformfell && !IsSideSwim() && justmoved <= 0)
7994 {
7995 1706 zfix my = y + 4;
7996 1706 needFall = true;
7997
2/2
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 3185 times.
3827 for (zfix ty = y+1; ty < my; ++ty)
7998 {
7999 //if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 1)) break;
8000
2/2
✓ Branch 0 taken 2121 times.
✓ Branch 1 taken 1064 times.
3185 if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 0))
8001 {
8002 1064 y = ty;
8003
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 915 times.
1064 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
8004 {
8005
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 15 times.
915 if(!slopeid)
8006 15 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
8007 915 onplatid = 5;
8008 915 }
8009 1064 needFall = false;
8010 1064 break;
8011 }
8012 2121 }
8013 1706 }
8014 125622 else needFall = true;
8015 // Continue falling.
8016
8017
4/4
✓ Branch 0 taken 254012 times.
✓ Branch 1 taken 7474 times.
✓ Branch 2 taken 135222 times.
✓ Branch 3 taken 118790 times.
261486 if(fall <= termv && needFall)
8018 {
8019 118790 inair = true;
8020
3/4
✓ Branch 0 taken 47129 times.
✓ Branch 1 taken 71661 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47129 times.
118790 if(fall != 0 || hoverclk>0)
8021 71661 jumping++;
8022
8023 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8024
2/2
✓ Branch 0 taken 116656 times.
✓ Branch 1 taken 2134 times.
118790 if(get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
8025 {
8026
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116656 times.
✓ Branch 4 taken 116065 times.
✓ Branch 5 taken 591 times.
233312 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8027
4/4
✓ Branch 0 taken 111190 times.
✓ Branch 1 taken 5466 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 110284 times.
116656 || (y<=(bigHitbox?9:1) &&
8028 // Extra checks if Smart Screen Scrolling is enabled
8029
2/6
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 906 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
906 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8030 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8031
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
5466 && fall < 0)
8032 {
8033 591 fall = jumping = 0; // Bumped his head
8034
8035 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8036
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 110 times.
591 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8037 {
8038 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8039 110 }
8040 591 }
8041 116656 }
8042 else
8043 {
8044
10/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2134 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2134 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2134 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 2128 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2128 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2128 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2128 times.
✓ Branch 14 taken 2133 times.
✓ Branch 15 taken 1 times.
4268 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8045
3/4
✓ Branch 0 taken 2128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 2091 times.
2128 || ((y<=0) &&
8046 // Extra checks if Smart Screen Scrolling is enabled
8047
2/6
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8048 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8049
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 && fall < 0)
8050 {
8051 1 fall = jumping = 0; // Bumped his head
8052 1 y -= y.getInt()%8; //fix coords
8053 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8054
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8055 {
8056 1 checkdamagecombos(x+4, x+12, y-1, y-1);
8057 1 }
8058 1 }
8059 }
8060
8061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118790 times.
118790 if(hoverclk > 0)
8062 {
8063 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8064 {
8065 --hoverclk;
8066 }
8067
8068 if(!hoverclk && !ladderx && !laddery)
8069 {
8070 fall += gravity3;
8071 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8072 }
8073 }
8074
5/12
✓ Branch 0 taken 85980 times.
✓ Branch 1 taken 32810 times.
✓ Branch 2 taken 47827 times.
✓ Branch 3 taken 38153 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47827 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
118790 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8075 {
8076 int32_t itemid = current_item_id(itype_hoverboots);
8077 if(hoverclk < 0)
8078 hoverclk = -hoverclk;
8079 else
8080 {
8081 fall = jumping = 0;
8082 if(itemsbuf[itemid].misc1)
8083 hoverclk = itemsbuf[itemid].misc1;
8084 else
8085 {
8086 hoverclk = 1;
8087 hoverflags |= HOV_INF;
8088 }
8089
8090
8091 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8092 }
8093 if(itemsbuf[itemid].wpn)
8094 decorations.add(new dHover(x, y, dHOVER, 0));
8095 }
8096
4/8
✓ Branch 0 taken 118790 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118790 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 118790 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 118790 times.
118790 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8097 {
8098 118790 fall += gravity3;
8099
8100 118790 }
8101 118790 }
8102 261486 }
8103 else // Topdown gravity
8104 {
8105
4/4
✓ Branch 0 taken 12292446 times.
✓ Branch 1 taken 6157073 times.
✓ Branch 2 taken 848 times.
✓ Branch 3 taken 6156225 times.
18449519 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8106
4/4
✓ Branch 0 taken 12292446 times.
✓ Branch 1 taken 6157073 times.
✓ Branch 2 taken 848 times.
✓ Branch 3 taken 6156225 times.
18449519 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
8107
4/4
✓ Branch 0 taken 6153441 times.
✓ Branch 1 taken 12296078 times.
✓ Branch 2 taken 12299710 times.
✓ Branch 3 taken 18453151 times.
18449519 if(z>0||fakez>0)
8108 {
8109
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24595788 switch(action)
8110 {
8111 case swimming:
8112 {
8113 diveclk=0;
8114 action=walking; FFCore.setHeroAction(walking);
8115
8116 break;
8117 }
8118 case waterhold1:
8119 {
8120 action=landhold1; FFCore.setHeroAction(landhold1);
8121 break;
8122 }
8123
8124 case waterhold2:
8125 {
8126 action=landhold2; FFCore.setHeroAction(landhold2);
8127 break;
8128 }
8129
8130 default:
8131 3632 break;
8132 }
8133 3632 }
8134
8135
2/2
✓ Branch 0 taken 16982 times.
✓ Branch 1 taken 18456783 times.
18473765 for(int32_t j=0; j<chainlinks.Count(); j++)
8136 {
8137 16982 chainlinks.spr(j)->z=z;
8138 16982 chainlinks.spr(j)->fakez=fakez;
8139 16982 }
8140
8141
2/2
✓ Branch 0 taken 18452272 times.
✓ Branch 1 taken 4511 times.
18456783 if(Lwpns.idFirst(wHookshot)>-1)
8142 {
8143 4511 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8144 4511 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8145 4511 }
8146
8147
2/2
✓ Branch 0 taken 18452051 times.
✓ Branch 1 taken 4732 times.
18456783 if(Lwpns.idFirst(wHSHandle)>-1)
8148 {
8149 4732 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8150 4732 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8151 4732 }
8152
8153
3/4
✓ Branch 0 taken 6153441 times.
✓ Branch 1 taken 12303342 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6153441 times.
18456783 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8154 {
8155
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6153441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6153441 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8156 {
8157
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 6153402 times.
6153441 if(fall > 0)
8158 {
8159
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✓ Branch 7 taken 6 times.
39 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8160 6 sfx(WAV_ZN1SPLASH,x.getInt());
8161
8162 39 stomping = true;
8163 39 }
8164 6153441 }
8165 6153441 z = fall = 0;
8166
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6153441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6153441 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8167 {
8168 6153441 jumping = 0;
8169
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 6153187 times.
6153441 if(check_pitslide(true) == -1)
8170 {
8171 6153187 hoverclk = 0;
8172 6153187 hoverflags = 0;
8173 6153187 }
8174
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 237 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
254 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8175 {
8176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!--hoverclk)
8177 {
8178 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8179 }
8180 17 }
8181 6153441 }
8182 6153441 }
8183
3/4
✓ Branch 0 taken 6157073 times.
✓ Branch 1 taken 12299710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6157073 times.
18456783 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8184 {
8185
3/4
✓ Branch 0 taken 3632 times.
✓ Branch 1 taken 6153441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3632 times.
6157073 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8186 {
8187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6153441 times.
6153441 if(fakefall > 0)
8188 {
8189 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8190 sfx(WAV_ZN1SPLASH,x.getInt());
8191
8192 stomping = true;
8193 }
8194 6153441 }
8195 6157073 fakez = fakefall = 0;
8196
3/4
✓ Branch 0 taken 3632 times.
✓ Branch 1 taken 6153441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3632 times.
6157073 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8197 {
8198 6153441 jumping = 0;
8199
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 6153187 times.
6153441 if(check_pitslide(true) == -1)
8200 {
8201 6153187 hoverclk = 0;
8202 6153187 hoverflags = 0;
8203 6153187 }
8204
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 237 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
254 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8205 {
8206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!--hoverclk)
8207 {
8208 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8209 }
8210 17 }
8211 6153441 }
8212 6157073 }
8213
8/10
✓ Branch 0 taken 6157050 times.
✓ Branch 1 taken 12299733 times.
✓ Branch 2 taken 6157050 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6149855 times.
✓ Branch 5 taken 7195 times.
✓ Branch 6 taken 6153464 times.
✓ Branch 7 taken 6153464 times.
✓ Branch 8 taken 6153464 times.
✗ Branch 9 not taken.
18456783 if(fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8214 {
8215
4/6
✓ Branch 0 taken 2725 times.
✓ Branch 1 taken 884 times.
✓ Branch 2 taken 2725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2725 times.
12303319 if(fall != 0 || fakefall != 0 || hoverclk>0)
8216 884 jumping++;
8217
8218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3609 times.
3609 if(hoverclk > 0)
8219 {
8220 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8221 {
8222 --hoverclk;
8223 }
8224
8225 if(!hoverclk)
8226 {
8227 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8228 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8229 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8230 }
8231 }
8232
9/16
✓ Branch 0 taken 3239 times.
✓ Branch 1 taken 370 times.
✓ Branch 2 taken 2735 times.
✓ Branch 3 taken 504 times.
✓ Branch 4 taken 2735 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 874 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 874 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 874 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3609 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3609 else if(((fall+(int32_t)(zinit.gravity2 / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8233 {
8234 if(hoverclk < 0)
8235 hoverclk = -hoverclk;
8236 else
8237 {
8238 fall = 0;
8239 fakefall = 0;
8240 int32_t itemid = current_item_id(itype_hoverboots);
8241 if(itemsbuf[itemid].misc1)
8242 hoverclk = itemsbuf[itemid].misc1;
8243 else
8244 {
8245 hoverclk = 1;
8246 hoverflags |= HOV_INF;
8247 }
8248 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8249 }
8250 decorations.add(new dHover(x, y, dHOVER, 0));
8251 }
8252 else
8253 {
8254
3/6
✓ Branch 0 taken 3609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3609 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3609 times.
3609 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8255
3/6
✓ Branch 0 taken 3609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3609 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3609 times.
✗ Branch 5 not taken.
3609 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8256 }
8257 3609 }
8258
1/2
✓ Branch 0 taken 6157073 times.
✗ Branch 1 not taken.
6157073 if (fakez<0) fakez = 0;
8259
1/2
✓ Branch 0 taken 6157073 times.
✗ Branch 1 not taken.
6157073 if (z<0) z = 0;
8260 }
8261
8262
1/2
✓ Branch 0 taken 6418559 times.
✗ Branch 1 not taken.
6418559 if(drunkclk)
8263 {
8264 --drunkclk;
8265 }
8266
8267
1/2
✓ Branch 0 taken 6418559 times.
✗ Branch 1 not taken.
6418559 if(lstunclock > 0)
8268 {
8269 // also cancel Hero's attack
8270 attackclk = 0;
8271
8272 if( FFCore.getHeroAction() != stunned )
8273 {
8274 tempaction=action; //update so future checks won't do this
8275 //action=freeze; //setting this makes the player invincible while stunned -V
8276 FFCore.setHeroAction(stunned);
8277 }
8278 --lstunclock;
8279 }
8280 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8281 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8282
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6418559 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6418559 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8283 {
8284 action=tempaction; FFCore.setHeroAction(tempaction);
8285 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8286 //action=none; FFCore.setHeroAction(none);
8287 }
8288
8289
1/2
✓ Branch 0 taken 6418559 times.
✗ Branch 1 not taken.
6418559 if( lbunnyclock > 0 )
8290 {
8291 --lbunnyclock;
8292 }
8293
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 6416634 times.
6418559 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8294 {
8295 1925 int32_t itemid = current_item_id(itype_pearl);
8296
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 1802 times.
1925 if(itemid > -1)
8297 {
8298
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 1 times.
123 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8299 1 lbunnyclock = 0;
8300 123 }
8301
2/2
✓ Branch 0 taken 1801 times.
✓ Branch 1 taken 1 times.
1802 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8302 {
8303 1 lbunnyclock = -1;
8304 1 }
8305 1925 }
8306
1/2
✓ Branch 0 taken 6416634 times.
✗ Branch 1 not taken.
6416634 else if(lbunnyclock == -1) //dmap-caused bunny effect
8307 {
8308 lbunnyclock = 0;
8309 }
8310
8311
13/18
✓ Branch 0 taken 6410724 times.
✓ Branch 1 taken 7835 times.
✓ Branch 2 taken 5698019 times.
✓ Branch 3 taken 712705 times.
✓ Branch 4 taken 5698019 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5698019 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1206 times.
✓ Branch 9 taken 5696813 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1206 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 5696210 times.
✓ Branch 15 taken 1809 times.
✓ Branch 16 taken 45294 times.
✓ Branch 17 taken 5650322 times.
6418559 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && (fall==0 || fakefall==0 || z>0 || fakez>0) && charging==0 && spins<=5
8312
2/2
✓ Branch 0 taken 5695616 times.
✓ Branch 1 taken 594 times.
5696210 && action != gothit)
8313 {
8314
2/3
✓ Branch 0 taken 2533324 times.
✓ Branch 1 taken 3116998 times.
✗ Branch 2 not taken.
5650322 switch(dir)
8315 {
8316 case up:
8317 case down:
8318 2533324 x=(x.getInt()+4)&0xFFF8;
8319 2533324 break;
8320
8321 case left:
8322 case right:
8323 3116998 y=(y.getInt()+4)&0xFFF8;
8324 3116998 break;
8325 }
8326 5650322 }
8327
8328
4/4
✓ Branch 0 taken 116936 times.
✓ Branch 1 taken 6301623 times.
✓ Branch 2 taken 77419 times.
✓ Branch 3 taken 39517 times.
6418559 if((watch==true) && clockclk)
8329 {
8330 39517 --clockclk;
8331
8332
2/2
✓ Branch 0 taken 39410 times.
✓ Branch 1 taken 107 times.
39517 if(!clockclk)
8333 {
8334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(cheat_superman==false)
8335 {
8336 107 setClock(false);
8337 107 }
8338
8339 107 watch=false;
8340
8341
2/2
✓ Branch 0 taken 54784 times.
✓ Branch 1 taken 107 times.
54891 for(int32_t i=0; i<eMAXGUYS; i++)
8342 {
8343
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 54784 times.
54790 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
8344 {
8345 6 addenemy(0,0,i,0);
8346 6 }
8347 54784 }
8348 107 }
8349 39517 }
8350
8351
3/4
✓ Branch 0 taken 6413827 times.
✓ Branch 1 taken 4732 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6413827 times.
6418559 if(hookshot_frozen || switch_hooked)
8352 {
8353
3/4
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 4511 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 221 times.
4732 if(hookshot_used || switch_hooked)
8354 {
8355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4511 times.
4511 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8356 4511 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8357
8358
3/4
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3888 times.
4511 if(pull_hero || switch_hooked)
8359 {
8360
3/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 563 times.
623 if(hs_switcher || switch_hooked)
8361 {
8362 60 hs_fix = false;
8363
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(switchhookclk)
8364 {
8365 60 --switchhookclk;
8366
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 59 times.
60 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8367 {
8368
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8369 reset_hookshot();
8370 else
8371 {
8372 1 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8373 1 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8374
8375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1) //Switching combos
8376 {
8377 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
8378 if(targpos < 176 && plpos < 176 && hooked_layerbits)
8379 {
8380 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8381 for(int q = max_layer; q > -1; --q)
8382 {
8383 if(!(hooked_layerbits & (1<<q)))
8384 continue; //non-switching layer
8385 mapscr* scr = FFCore.tempScreens[q];
8386 newcombo const& cmb = combobuf[scr->data[targpos]];
8387 int32_t srcfl = scr->sflag[targpos];
8388 newcombo const& comb2 = combobuf[scr->data[plpos]];
8389 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
8390 //{Check push status
8391 bool isFakePush = false;
8392 if(cmb.type == cSWITCHHOOK)
8393 {
8394 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8395 isFakePush = true;
8396 }
8397 bool isPush = isFakePush;
8398 if(!isPush) switch(srcfl)
8399 {
8400 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8401 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8402 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8403 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8404 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8405 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8406 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8407 isPush = true;
8408 }
8409 if(!isPush) switch(cmb.flag)
8410 {
8411 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8412 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8413 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8414 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8415 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8416 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8417 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8418 isPush = true;
8419 }
8420 if(srcfl==mfPUSHED) isPush = false;
8421 //}
8422 if(cmb.type == cSWITCHHOOK) //custom flags and such
8423 {
8424 if(cmb.usrflags&cflag3) //Breaks on swap
8425 {
8426 int32_t it = -1;
8427 int32_t thedropset = -1;
8428 if(cmb.usrflags&cflag4) //drop item
8429 {
8430 if(cmb.usrflags&cflag5)
8431 it = cmb.attribytes[2];
8432 else
8433 {
8434 it = select_dropitem(cmb.attribytes[2]);
8435 thedropset = cmb.attribytes[2];
8436 }
8437 }
8438
8439 breakable* br = new breakable(x, y, zfix(0),
8440 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
8441 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8442 br->switch_hooked = true;
8443 decorations.add(br);
8444 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8445 hooked_undercombos[q] = -1;
8446
8447 if(cmb.usrflags&cflag6)
8448 {
8449 scr->data[targpos]++;
8450 }
8451 else
8452 {
8453 scr->data[targpos] = scr->undercombo;
8454 scr->cset[targpos] = scr->undercset;
8455 if(cmb.usrflags&cflag2)
8456 scr->sflag[targpos] = 0;
8457 }
8458 }
8459 else if(isPush)
8460 {
8461 //Simulate a block clicking into place
8462 movingblock mtemp;
8463 mtemp.clear();
8464 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8465 mtemp.dir = getPushDir(scr->sflag[targpos]);
8466 if(mtemp.dir < 0)
8467 mtemp.dir = getPushDir(cmb.flag);
8468 mtemp.clk = 1;
8469 mtemp.force_many = isFakePush;
8470 mtemp.no_icy = true;
8471 mtemp.animate(0);
8472 if((mtemp.bhole || mtemp.trigger)
8473 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8474 || comb2.flag == mfBLOCKTRIGGER
8475 || comb2.flag == mfBLOCKHOLE))
8476 {
8477 scr->data[targpos] = scr->undercombo;
8478 scr->cset[targpos] = scr->undercset;
8479 scr->sflag[targpos] = 0;
8480 }
8481 else
8482 {
8483 scr->data[targpos] = c;
8484 scr->cset[targpos] = cs;
8485 if(cmb.usrflags&cflag2)
8486 scr->sflag[targpos] = fl;
8487 else
8488 scr->sflag[targpos] = 0;
8489 }
8490 }
8491 else
8492 {
8493 scr->data[plpos] = scr->data[targpos];
8494 scr->cset[plpos] = scr->cset[targpos];
8495 if(cmb.usrflags&cflag2)
8496 scr->sflag[plpos] = scr->sflag[targpos];
8497 scr->data[targpos] = c;
8498 scr->cset[targpos] = cs;
8499 if(cmb.usrflags&cflag2)
8500 scr->sflag[targpos] = fl;
8501 }
8502 }
8503 else if(isCuttableType(cmb.type)) //Break and drop effects
8504 {
8505 int32_t breakcs = scr->cset[targpos];
8506 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8507 {
8508 scr->data[targpos]++;
8509 }
8510 else
8511 {
8512 scr->data[targpos] = scr->undercombo;
8513 scr->cset[targpos] = scr->undercset;
8514 scr->sflag[targpos] = 0;
8515 }
8516
8517 int32_t it = -1;
8518 int32_t thedropset = -1;
8519 if(isCuttableItemType(cmb.type)) //Drop an item
8520 {
8521 if ( (cmb.usrflags&cflag2) )
8522 {
8523 if(cmb.usrflags&cflag11)
8524 it = cmb.attribytes[1];
8525 else
8526 {
8527 it = select_dropitem(cmb.attribytes[1]);
8528 thedropset = cmb.attribytes[1];
8529 }
8530 }
8531 else
8532 {
8533 it = select_dropitem(12);
8534 thedropset = 12;
8535 }
8536 }
8537
8538 byte breaksfx = 0;
8539 if(get_bit(quest_rules,qr_MORESOUNDS)) //SFX
8540 {
8541 if (cmb.usrflags&cflag3)
8542 {
8543 breaksfx = cmb.attribytes[2];
8544 }
8545 else if(isBushType(cmb.type)
8546 || isFlowersType(cmb.type)
8547 || isGrassType(cmb.type))
8548 {
8549 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8550 }
8551 }
8552
8553 //Clipping sprite
8554 int16_t decotype = (cmb.usrflags & cflag1) ?
8555 ((cmb.usrflags & cflag10)
8556 ? (cmb.attribytes[0])
8557 : (-1))
8558 : (0);
8559 if(decotype > 3) decotype = 0;
8560 if(!decotype)
8561 decotype = (isBushType(cmb.type) ? 1
8562 : (isFlowersType(cmb.type) ? 2
8563 : (isGrassType(cmb.type) ? 3
8564 : ((cmb.usrflags & cflag1) ? -1
8565 : -2))));
8566
8567 breakable* br = new breakable(x, y, zfix(0),
8568 cmb, breakcs, it, thedropset, breaksfx,
8569 decotype, cmb.attribytes[0], switchhookclk);
8570 br->switch_hooked = true;
8571 decorations.add(br);
8572 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8573 hooked_undercombos[q] = -1;
8574 }
8575 else //Unknown type, just swap combos.
8576 {
8577 if(isPush)
8578 {
8579 //Simulate a block clicking into place
8580 movingblock mtemp;
8581 mtemp.clear();
8582 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8583 mtemp.dir = getPushDir(scr->sflag[targpos]);
8584 if(mtemp.dir < 0)
8585 mtemp.dir = getPushDir(cmb.flag);
8586 mtemp.clk = 1;
8587 mtemp.animate(0);
8588 if(mtemp.bhole || mtemp.trigger)
8589 {
8590 scr->data[targpos] = scr->undercombo;
8591 scr->cset[targpos] = scr->undercset;
8592 scr->sflag[targpos] = 0;
8593 }
8594 else
8595 {
8596 scr->data[targpos] = c;
8597 scr->cset[targpos] = cs;
8598 scr->sflag[targpos] = 0;
8599 }
8600 }
8601 else
8602 {
8603 scr->data[plpos] = scr->data[targpos];
8604 scr->cset[plpos] = scr->cset[targpos];
8605 scr->data[targpos] = c;
8606 scr->cset[targpos] = cs;
8607 }
8608 }
8609 }
8610 if(switchhook_cost_item > -1)
8611 paymagiccost(switchhook_cost_item);
8612 zfix tx = x, ty = y;
8613 //Position the player at the combo
8614 x = COMBOX(targpos);
8615 y = COMBOY(targpos);
8616 dir = oppositeDir[dir];
8617 if(w && hw)
8618 {
8619 //Calculate chain shift
8620 zfix dx = (x-tx);
8621 zfix dy = (y-ty);
8622 if(w->dir < 4)
8623 {
8624 if(w->dir & 2)
8625 dx = 0;
8626 else dy = 0;
8627 }
8628 //Position the hook head at the handle
8629 w->x = hw->x + dx;
8630 w->y = hw->y + dy;
8631 w->dir = oppositeDir[w->dir];
8632 w->doAutoRotate(true);
8633 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8634 w->flip ^= hflip;
8635 //Position the handle appropriately
8636 hw->x = x-(hw->x-tx);
8637 hw->y = y-(hw->y-ty);
8638 hw->dir = oppositeDir[hw->dir];
8639 hw->doAutoRotate(true);
8640 hw->flip ^= hflip;
8641 //Move chains
8642 for(int32_t j=0; j<chainlinks.Count(); j++)
8643 {
8644 chainlinks.spr(j)->x += dx;
8645 chainlinks.spr(j)->y += dy;
8646 }
8647 }
8648 hooked_combopos = plpos; //flip positions
8649 }
8650 else reset_hookshot();
8651 }
8652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object) //Switching an object
8653 {
8654
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(switchhook_cost_item > -1)
8655 paymagiccost(switchhook_cost_item);
8656 1 zfix tx = x, ty = y;
8657 //Position the player at the object
8658 1 x = switching_object->x;
8659 1 y = switching_object->y;
8660 1 dir = oppositeDir[dir];
8661 //Position the object at the player
8662 1 switching_object->x = tx;
8663 1 switching_object->y = ty;
8664
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
8665 switching_object->dir = oppositeDir[switching_object->dir];
8666 1 solid_update(false);
8667 1 switching_object->solid_update(false);
8668
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(item* it = dynamic_cast<item*>(switching_object))
8669 {
8670 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
8671 {
8672 movefairynew2(it->x, it->y, *it);
8673 }
8674 }
8675
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(w && hw) //!TODO No fucking clue if diagonals work
8676 {
8677 //Calculate chain shift
8678 1 zfix dx = (x-tx);
8679 1 zfix dy = (y-ty);
8680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w->dir < 4)
8681 {
8682
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->dir & 2)
8683 1 dx = 0;
8684 else dy = 0;
8685 1 }
8686 //Position the hook head at the handle
8687 1 w->x = hw->x + dx;
8688 1 w->y = hw->y + dy;
8689 1 w->dir = oppositeDir[w->dir];
8690 1 w->doAutoRotate(true);
8691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8692 1 w->flip ^= hflip;
8693 1 w->solid_update(false);
8694 //Position the handle appropriately
8695 1 hw->x = x-(hw->x-tx);
8696 1 hw->y = y-(hw->y-ty);
8697 1 hw->dir = oppositeDir[hw->dir];
8698 1 hw->doAutoRotate(true);
8699 1 hw->flip ^= hflip;
8700 1 hw->solid_update(false);
8701 //Move chains
8702
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
8703 {
8704 5 chainlinks.spr(j)->x += dx;
8705 5 chainlinks.spr(j)->y += dy;
8706 5 }
8707 1 }
8708 1 }
8709 }
8710 1 }
8711
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 1 times.
59 else if(!switchhookclk)
8712 {
8713 1 reset_hookshot();
8714 1 }
8715 60 }
8716 else reset_hookshot();
8717 60 }
8718 else
8719 {
8720 sprite *t;
8721 int32_t i;
8722
8723
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 579 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 563 times.
579 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
8724 {
8725 /* do nothing */
8726 16 }
8727
8728 563 t = Lwpns.spr(i);
8729
8730
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 563 times.
1705 for(i=0; i<Lwpns.Count(); i++)
8731 {
8732 1142 sprite *s = Lwpns.spr(i);
8733
8734
2/2
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 563 times.
1142 if(s->id==wHookshot)
8735 {
8736
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 500 times.
563 if (abs((s->y) - y) >= 1)
8737 {
8738
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 38 times.
63 if((s->y)>y)
8739 {
8740 38 y+=4;
8741
8742
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(Lwpns.idFirst(wHSHandle)!=-1)
8743 {
8744 38 t->y+=4;
8745 38 }
8746
8747 38 hs_starty+=4;
8748 38 }
8749
8750
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 25 times.
63 if((s->y)<y)
8751 {
8752 25 y-=4;
8753
8754
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(Lwpns.idFirst(wHSHandle)!=-1)
8755 {
8756 25 t->y-=4;
8757 25 }
8758
8759 25 hs_starty-=4;
8760 25 }
8761 63 }
8762 else
8763 {
8764 500 y = (s->y);
8765 }
8766
2/2
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 63 times.
563 if (abs((s->x) - x) >= 1)
8767 {
8768
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 338 times.
500 if((s->x)>x)
8769 {
8770 338 x+=4;
8771
8772
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 if(Lwpns.idFirst(wHSHandle)!=-1)
8773 {
8774 338 t->x+=4;
8775 338 }
8776
8777 338 hs_startx+=4;
8778 338 }
8779
8780
2/2
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 162 times.
500 if((s->x)<x)
8781 {
8782 162 x-=4;
8783
8784
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if(Lwpns.idFirst(wHSHandle)!=-1)
8785 {
8786 162 t->x-=4;
8787 162 }
8788
8789 162 hs_startx-=4;
8790 162 }
8791 500 }
8792 else
8793 {
8794 63 x = (s->x);
8795 }
8796 563 }
8797 1142 }
8798 }
8799 623 }
8800 4511 }
8801 else
8802 {
8803 221 Lwpns.del(Lwpns.idFirst(wHSHandle));
8804 221 reset_hookshot();
8805 }
8806
8807
1/2
✓ Branch 0 taken 4732 times.
✗ Branch 1 not taken.
4732 if(hs_fix)
8808 {
8809 if(dir==up)
8810 {
8811 y=int32_t(y+7)&0xF0;
8812 }
8813
8814 if(dir==down)
8815 {
8816 y=int32_t(y+7)&0xF0;
8817 }
8818
8819 if(dir==left)
8820 {
8821 x=int32_t(x+7)&0xF0;
8822 }
8823
8824 if(dir==right)
8825 {
8826 x=int32_t(x+7)&0xF0;
8827 }
8828
8829 hs_fix=false;
8830 }
8831
8832 4732 }
8833
8834
2/2
✓ Branch 0 taken 370914 times.
✓ Branch 1 taken 6047645 times.
6418559 if(!get_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP))
8835 {
8836
2/2
✓ Branch 0 taken 3382 times.
✓ Branch 1 taken 6044263 times.
6047645 if(DrunkrLbtn())
8837 3382 selectNextBWpn(SEL_LEFT);
8838
2/2
✓ Branch 0 taken 6040553 times.
✓ Branch 1 taken 3710 times.
6044263 else if(DrunkrRbtn())
8839 3710 selectNextBWpn(SEL_RIGHT);
8840 6047645 }
8841
4/4
✓ Branch 0 taken 381005 times.
✓ Branch 1 taken 6037554 times.
✓ Branch 2 taken 370350 times.
✓ Branch 3 taken 10655 times.
6418559 if (get_bit(quest_rules, qr_SELECTAWPN) && get_bit(quest_rules, qr_USE_EX1_EX2_INVENTORYSWAP))
8842 {
8843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10655 times.
10655 if (rEx3btn())
8844 selectNextAWpn(SEL_LEFT);
8845
2/2
✓ Branch 0 taken 10654 times.
✓ Branch 1 taken 1 times.
10655 else if (rEx4btn())
8846 1 selectNextAWpn(SEL_RIGHT);
8847 10655 }
8848
8849
2/2
✓ Branch 0 taken 6418279 times.
✓ Branch 1 taken 280 times.
6418559 if(rPbtn())
8850 {
8851
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 277 times.
280 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
8852 277 onViewMap();
8853 280 }
8854
2/2
✓ Branch 0 taken 2708324 times.
✓ Branch 1 taken 6418559 times.
9126883 for(int32_t i=0; i<Lwpns.Count(); i++)
8855 {
8856 2708324 weapon *w = ((weapon*)Lwpns.spr(i));
8857
8858
6/6
✓ Branch 0 taken 2687411 times.
✓ Branch 1 taken 20913 times.
✓ Branch 2 taken 2394388 times.
✓ Branch 3 taken 293023 times.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 2394315 times.
2708324 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
8859 314009 addsparkle(i);
8860 2708324 }
8861
8862
1/2
✓ Branch 0 taken 6418559 times.
✗ Branch 1 not taken.
6418559 if(Lwpns.idCount(wPhantom))
8863 {
8864 addsparkle2(pDIVINEFIREROCKET,pDIVINEFIREROCKETTRAIL);
8865 addsparkle2(pDIVINEFIREROCKETRETURN,pDIVINEFIREROCKETTRAILRETURN);
8866 addsparkle2(pDIVINEPROTECTIONROCKET1,pDIVINEPROTECTIONROCKETTRAIL1);
8867 addsparkle2(pDIVINEPROTECTIONROCKET2,pDIVINEPROTECTIONROCKETTRAIL2);
8868 addsparkle2(pDIVINEPROTECTIONROCKETRETURN1,pDIVINEPROTECTIONROCKETTRAILRETURN1);
8869 addsparkle2(pDIVINEPROTECTIONROCKETRETURN2,pDIVINEPROTECTIONROCKETTRAILRETURN2);
8870 }
8871
8872 // Pay magic cost for Byrna beams
8873
8874 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
8875
2/2
✓ Branch 0 taken 6418486 times.
✓ Branch 1 taken 73 times.
6418559 if(Lwpns.idCount(wCByrna))
8876 {
8877 73 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
8878 73 int32_t itemid = ew->parentitem;
8879
8880
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
73 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
8881 {
8882 for(int32_t i=0; i<Lwpns.Count(); i++)
8883 {
8884 weapon *w = ((weapon*)Lwpns.spr(i));
8885
8886 if(w->id==wCByrna)
8887 {
8888 w->dead=1;
8889 }
8890
8891 }
8892 //kill the sound effect for the orbits -Z 14FEB2019
8893 stop_sfx(itemsbuf[itemid].usesound);
8894 }
8895 73 else paymagiccost(itemid);
8896 73 }
8897
8898
3/4
✓ Branch 0 taken 6414927 times.
✓ Branch 1 taken 3632 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6414927 times.
6418559 if(z==0&&fakez==0)
8899 {
8900 6414927 switchblock_z = 0;
8901
1/2
✓ Branch 0 taken 6414927 times.
✗ Branch 1 not taken.
6414927 if(switchblock_offset)
8902 {
8903 switchblock_offset=false;
8904 yofs += 8;
8905 }
8906 6414927 }
8907
2/2
✓ Branch 0 taken 261486 times.
✓ Branch 1 taken 6157073 times.
6418559 if(!isSideViewHero())
8908 {
8909 6157073 int32_t tx = x.getInt()+8,
8910 6157073 ty = y.getInt()+8;//(bigHitbox?8:12);
8911
4/4
✓ Branch 0 taken 6156826 times.
✓ Branch 1 taken 247 times.
✓ Branch 2 taken 214 times.
✓ Branch 3 taken 6156612 times.
6157073 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
8912 {
8913
2/2
✓ Branch 0 taken 6156612 times.
✓ Branch 1 taken 18469836 times.
24626448 for(int32_t q = 0; q < 3; ++q)
8914 {
8915
4/4
✓ Branch 0 taken 12313224 times.
✓ Branch 1 taken 6156612 times.
✓ Branch 2 taken 10702329 times.
✓ Branch 3 taken 1610895 times.
18469836 if(q && !tmpscr2[q-1].valid) continue;
8916 7767507 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
8917
3/4
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 7766540 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
7767507 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
8918 int32_t b = 1;
8919 if(tx&8) b <<= 2;
8920 if(ty&8) b <<= 1;
8921 b |= (b<<4); //check equivalent effect flag too
8922 if((cmb.walk&b)==b) //solid and effecting
8923 {
8924 if(z==0&&fakez==0)
8925 {
8926 if(cmb.usrflags&cflag10)
8927 {
8928 if(!switchblock_offset)
8929 {
8930 switchblock_offset=true;
8931 yofs -= 8;
8932 }
8933 }
8934 else
8935 {
8936 if(switchblock_offset)
8937 {
8938 switchblock_offset=false;
8939 yofs += 8;
8940 }
8941 }
8942 }
8943 if(cmb.attributes[2]>0 && switchblock_z>=0)
8944 {
8945 if(z==0&&fakez==0)
8946 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
8947 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
8948 {
8949 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
8950 }
8951 }
8952 else switchblock_z = -1;
8953 break;
8954 }
8955 }
8956 6156612 }
8957 6157073 }
8958 6418559 ClearhitHeroUIDs(); //clear them before we advance.
8959 6418559 checkhit();
8960
8961 6418559 bool forcedeath = dying_flags&DYING_FORCED;
8962 6418559 bool norev = (dying_flags&DYING_NOREV);
8963
4/6
✓ Branch 0 taken 6418559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✓ Branch 3 taken 6418439 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 120 times.
6418559 if(forcedeath || (game->get_life()<=0 && !immortal))
8964 {
8965
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(forcedeath)
8966 game->set_life(0);
8967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!norev)
8968
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30720 times.
30840 for(size_t slot = 0; slot < 256; ++slot)
8969 {
8970
1/2
✓ Branch 0 taken 30720 times.
✗ Branch 1 not taken.
30720 if(size_t bind = game->get_bottle_slot(slot))
8971 {
8972 bottletype const* bt = &QMisc.bottle_types[bind-1];
8973 if(!(bt->flags&BTFLAG_AUTOONDEATH))
8974 continue;
8975 word toFill[3] = { 0 };
8976 for(size_t q = 0; q < 3; ++q)
8977 {
8978 char c = bt->counter[q];
8979 if(c > -1)
8980 {
8981 if(bt->flags & (1<<q))
8982 {
8983 toFill[q] = (bt->amount[q]==100)
8984 ? game->get_maxcounter(c)
8985 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
8986 }
8987 else toFill[q] = bt->amount[q];
8988 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
8989 {
8990 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
8991 }
8992 }
8993 }
8994 if(bt->flags & BTFLAG_CURESWJINX)
8995 {
8996 swordclk = 0;
8997 verifyAWpn();
8998 }
8999 if(bt->flags & BTFLAG_CUREITJINX)
9000 itemclk = 0;
9001 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
9002 {
9003 int32_t itemid = find_bottle_for_slot(slot,true);
9004 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
9005 if(itemid > -1)
9006 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
9007 for(size_t q = 0; q < 20; ++q)
9008 do_death_refill_waitframe();
9009 double inc = max/60.0; //1 second
9010 double xtra[3]{ 0 };
9011 for(size_t q = 0; q < 60; ++q)
9012 {
9013 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
9014 sfx(QMisc.miscsfx[sfxREFILL]);
9015 for(size_t j = 0; j < 3; ++j)
9016 {
9017 xtra[j] += inc;
9018 word f = floor(xtra[j]);
9019 xtra[j] -= f;
9020 if(toFill[j] > f)
9021 {
9022 toFill[j] -= f;
9023 game->change_counter(f,bt->counter[j]);
9024 }
9025 else if(toFill[j])
9026 {
9027 game->change_counter(toFill[j],bt->counter[j]);
9028 toFill[j] = 0;
9029 }
9030 }
9031 do_death_refill_waitframe();
9032 }
9033 for(size_t j = 0; j < 3; ++j)
9034 {
9035 if(toFill[j])
9036 {
9037 game->change_counter(toFill[j],bt->counter[j]);
9038 toFill[j] = 0;
9039 }
9040 }
9041 for(size_t q = 0; q < 20; ++q)
9042 do_death_refill_waitframe();
9043 }
9044 game->set_bottle_slot(slot,bt->next_type);
9045 if(game->get_life() > 0)
9046 {
9047 dying_flags = 0;
9048 forcedeath = false;
9049 break; //Revived! Stop drinking things...
9050 }
9051 }
9052 30840 }
9053
9054
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 106 times.
120 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9055 {
9056
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9057 {
9058 // So scripts can have one frame to handle hp zero events
9059
3/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 12 times.
14 if(norev || false == (last_hurrah = !last_hurrah))
9060 {
9061 2 dying_flags = 0;
9062 2 drunkclk=0;
9063 2 lstunclock = 0;
9064 2 is_conveyor_stunned = 0;
9065 2 FFCore.setHeroAction(dying);
9066 2 FFCore.deallocateAllArrays(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME);
9067 2 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE);
9068 2 ALLOFF(true,true);
9069 2 GameFlags |= GAMEFLAG_NO_F6;
9070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!debug_enabled)
9071 {
9072 2 Paused=false;
9073 2 }
9074
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9075 {
9076 FFCore.runOnDeathEngine();
9077 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9078 }
9079 2 Playing = false;
9080 2 heroDeathAnimation();
9081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9082 {
9083 2 Playing = true;
9084 2 FFCore.runOnDeathEngine();
9085 2 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9086 2 Playing = false;
9087 2 }
9088 2 GameFlags &= ~GAMEFLAG_NO_F6;
9089 2 ALLOFF(true,true);
9090 2 return true;
9091 }
9092 12 }
9093 12 }
9094 else //2.50.x
9095 {
9096 // So scripts can have one frame to handle hp zero events
9097
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 53 times.
106 if(false == (last_hurrah = !last_hurrah))
9098 {
9099 53 drunkclk=0;
9100 53 heroDeathAnimation();
9101
9102 53 return true;
9103 }
9104 }
9105 65 }
9106 6418439 else last_hurrah=false;
9107
9108
2/2
✓ Branch 0 taken 6386055 times.
✓ Branch 1 taken 32449 times.
6418504 if(swordclk>0)
9109 {
9110 32449 --swordclk;
9111
2/2
✓ Branch 0 taken 32294 times.
✓ Branch 1 taken 155 times.
32449 if(!swordclk) verifyAWpn();
9112 32449 }
9113
2/2
✓ Branch 0 taken 6414446 times.
✓ Branch 1 taken 4058 times.
6418504 if(itemclk>0)
9114 4058 --itemclk;
9115
9116
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 6418212 times.
6418504 if(inwallm)
9117 {
9118 292 attackclk=0;
9119 292 herostep();
9120
9121
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(CarryHero()==false)
9122 3 restart_level();
9123
9124 292 solid_update(false);
9125 292 return false;
9126 }
9127
9128
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6418211 times.
6418212 if(ewind_restart)
9129 {
9130 1 attackclk=0;
9131 1 restart_level();
9132 1 xofs=0;
9133 1 action=none; FFCore.setHeroAction(none);
9134 1 ewind_restart=false;
9135 1 solid_update(false);
9136 1 return false;
9137 }
9138
9139
2/2
✓ Branch 0 taken 6412088 times.
✓ Branch 1 taken 6123 times.
6418211 if(hopclk)
9140 {
9141 6123 action=hopping; FFCore.setHeroAction(hopping);
9142 6123 }
9143
2/2
✓ Branch 0 taken 6418001 times.
✓ Branch 1 taken 210 times.
6418211 if(fallclk)
9144 {
9145 210 action=falling; FFCore.setHeroAction(falling);
9146 210 }
9147
9148 6418211 handle_passive_buttons();
9149
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 6418091 times.
6418211 if(liftclk)
9150 {
9151
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(lift_wpn)
9152 {
9153 120 action=lifting; FFCore.setHeroAction(lifting);
9154 120 }
9155 else
9156 {
9157 liftclk = 0;
9158 tliftclk = 0;
9159 }
9160 120 }
9161
2/2
✓ Branch 0 taken 6417777 times.
✓ Branch 1 taken 314 times.
6418091 else if(lift_wpn)
9162 {
9163 314 handle_lift(false);
9164 314 }
9165
9166
9167 // get user input or do other animation
9168 6418211 freeze_guys=false; // reset this flag, set it again if holding
9169
9170
14/16
✓ Branch 0 taken 6376703 times.
✓ Branch 1 taken 41508 times.
✓ Branch 2 taken 6363309 times.
✓ Branch 3 taken 13394 times.
✓ Branch 4 taken 6362659 times.
✓ Branch 5 taken 650 times.
✓ Branch 6 taken 6362529 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 6362529 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362529 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6346168 times.
✓ Branch 13 taken 16361 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 6346146 times.
6418211 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9171 {
9172 22 holdclk=0;
9173 22 }
9174
9175 6418211 active_shield_id = refreshActiveShield();
9176 6418211 bool sh = active_shield_id > -1;
9177 6418211 itemdata const& shield = itemsbuf[active_shield_id];
9178 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9179 6418211 shield_forcedir = -1;
9180
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6418211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6418211 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9181 {
9182 shield_forcedir = dir;
9183 }
9184
1/2
✓ Branch 0 taken 6418211 times.
✗ Branch 1 not taken.
6418211 if(sh != shield_active) //Toggle active shield on/off
9185 {
9186 shield_active = sh;
9187 if(sh) //Toggle active shield on
9188 {
9189 sfx(shield.usesound2); //'Activate' sfx
9190 }
9191 }
9192
9193 6418211 bool isthissolid = false;
9194
11/12
✓ Branch 0 taken 64741 times.
✓ Branch 1 taken 780 times.
✓ Branch 2 taken 640 times.
✓ Branch 3 taken 104764 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 54902 times.
✓ Branch 6 taken 6128588 times.
✓ Branch 7 taken 47576 times.
✓ Branch 8 taken 210 times.
✓ Branch 9 taken 6123 times.
✓ Branch 10 taken 9767 times.
✓ Branch 11 taken 120 times.
6418211 switch(action)
9195 {
9196 case gothit:
9197
2/2
✓ Branch 0 taken 46153 times.
✓ Branch 1 taken 1423 times.
47576 if(attackclk)
9198
2/2
✓ Branch 0 taken 1235 times.
✓ Branch 1 taken 188 times.
1611 if(!doattack())
9199 {
9200 188 attackclk=spins=0;
9201 188 tapping=false;
9202 188 }
9203
9204 47576 break;
9205
9206 case drowning:
9207 case lavadrowning:
9208 case sidedrowning:
9209 {
9210 640 herostep(); // maybe this line should be elsewhere?
9211
9212 //!DROWN
9213 // Helpful comment to find drowning -Dimi
9214
9215 640 drop_liftwpn();
9216
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 10 times.
640 if(--drownclk==0)
9217 {
9218 10 action=none; FFCore.setHeroAction(none);
9219 10 int32_t water = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9220 10 int32_t damage = combobuf[water].attributes[0]/10000L;
9221 //if (damage == 0 && !(combobuf[water].usrflags&cflag7)) damage = (game->get_hp_per_heart()/4);
9222 10 drownCombo = 0;
9223
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (combobuf[water].type != cWATER) damage = 4;
9224
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if(cheat_superman && damage > 0)
9225 damage = 0;
9226
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(damage)
9227 10 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9228 10 go_respawn_point();
9229 10 hclk=48;
9230 10 }
9231
9232 640 break;
9233 }
9234 case falling:
9235 {
9236 210 herostep();
9237 210 pitfall();
9238 210 break;
9239 }
9240 case freeze:
9241 case sideswimfreeze:
9242 case scrolling:
9243 104764 break;
9244
9245 case casting:
9246 case sideswimcasting:
9247 {
9248 if(magicitem==-1)
9249 {
9250 action=none; FFCore.setHeroAction(none);
9251 }
9252
9253 break;
9254 }
9255 case landhold1:
9256 case landhold2:
9257 {
9258
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 54480 times.
54902 if(--holdclk <= 0)
9259 {
9260 //restart music
9261
4/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 359 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 28 times.
422 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9262 28 playLevelMusic();
9263
9264 422 action=none; FFCore.setHeroAction(none);
9265 422 post_item_collect();
9266 422 }
9267 else
9268 54480 freeze_guys=true;
9269
9270 54902 break;
9271 }
9272 case waterhold1:
9273 case waterhold2:
9274 case sidewaterhold1:
9275 case sidewaterhold2:
9276 {
9277 780 diveclk=0;
9278
9279
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 774 times.
780 if(--holdclk <= 0)
9280 {
9281 //restart music
9282
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9283 playLevelMusic();
9284
9285 6 SetSwim();
9286 6 post_item_collect();
9287 6 }
9288 else
9289 774 freeze_guys=true;
9290
9291 780 break;
9292 }
9293 case hopping:
9294 {
9295
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6123 if(DRIEDLAKE)
9296 {
9297 action=none; FFCore.setHeroAction(none);
9298 hopclk = 0;
9299 diveclk = 0;
9300 break;
9301 }
9302
9303 6123 do_hopping();
9304 6123 break;
9305 }
9306 case inwind:
9307 {
9308 9767 int32_t i=Lwpns.idFirst(wWind);
9309
9310
2/2
✓ Branch 0 taken 9634 times.
✓ Branch 1 taken 133 times.
9767 if(i<0)
9311 {
9312 133 bool exit=false;
9313
9314
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 67 times.
133 if(whirlwind==255)
9315 {
9316 66 exit=true;
9317 66 }
9318
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(y<=0 && dir==up) y=-1;
9319
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(y>=160 && dir==down) y=161;
9320
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(x<=0 && dir==left) x=-1;
9321
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
67 else if(x>=240 && dir==right) x=241;
9322 else exit=true;
9323
9324
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 66 times.
133 if(exit)
9325 {
9326 66 action=none; FFCore.setHeroAction(none);
9327 66 xofs=0;
9328 66 whirlwind=0;
9329 66 lstep=0;
9330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if ( dontdraw < 2 ) dontdraw=0;
9331 66 set_respawn_point();
9332 66 }
9333 133 }
9334 /*
9335 else if (((weapon*)Lwpns.spr(i))->dead==1)
9336 {
9337 whirlwind=255;
9338 }
9339 */
9340 else
9341 {
9342 9634 x=Lwpns.spr(i)->x;
9343 9634 y=Lwpns.spr(i)->y;
9344 9634 dir=Lwpns.spr(i)->dir;
9345 }
9346 }
9347 9767 break;
9348 case lifting:
9349 120 handle_lift();
9350 120 break;
9351
9352 case sideswimming:
9353 case sideswimattacking:
9354 case sideswimhit:
9355 case swimhit:
9356 case swimming:
9357 {
9358
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64741 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64741 if(DRIEDLAKE)
9359 {
9360 action=none; FFCore.setHeroAction(none);
9361 hopclk=0;
9362 break;
9363 }
9364
9365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64741 times.
64741 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9366
9367
4/4
✓ Branch 0 taken 32339 times.
✓ Branch 1 taken 32402 times.
✓ Branch 2 taken 259 times.
✓ Branch 3 taken 32080 times.
64741 if((frame&1) && !shouldbreak)
9368 32080 herostep();
9369
9370
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 64741 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64741 times.
✓ Branch 4 taken 2282 times.
✓ Branch 5 taken 62459 times.
67023 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9371
4/6
✓ Branch 0 taken 62459 times.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
64741 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
9372
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
2282 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9373
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
64741 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
9374
4/4
✓ Branch 0 taken 63474 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 63474 times.
✓ Branch 3 taken 1267 times.
64741 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9375 {
9376
4/4
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1255 times.
✓ Branch 3 taken 1 times.
2523 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
9377
4/4
✓ Branch 0 taken 1262 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1256 times.
✓ Branch 3 taken 6 times.
1264 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
9378 {
9379 12 hopclk=0;
9380 12 diveclk=0;
9381
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9382 else {action=attacking; FFCore.setHeroAction(attacking);}
9383 12 hopdir=-1;
9384 12 }
9385 1267 }
9386
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 64214 times.
64741 if (shouldbreak) break;
9387
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 64202 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
64214 if (action == swimming || action == sideswimming || action == sideswimattacking)
9388 {
9389 64202 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64202 times.
64202 if (combobuf[watercheck].usrflags&cflag2)
9391 {
9392 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9393 {
9394 onpassivedmg = true;
9395 if (damageovertimeclk == 0)
9396 {
9397 int32_t curhp = game->get_life();
9398 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9399 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9400 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9401 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9402 {
9403 hclk = 48;
9404 hitdir = -1;
9405 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9406 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9407 }
9408 }
9409 if (combobuf[watercheck].attribytes[1] > 0)
9410 {
9411 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9412 else --damageovertimeclk;
9413 }
9414 else damageovertimeclk = 0;
9415 }
9416 else damageovertimeclk = 0;
9417 }
9418 64202 else damageovertimeclk = 0;
9419 //combobuf[watercheck].attributes[0]
9420 64202 }
9421
9422 64214 }
9423 [[fallthrough]];
9424 default:
9425 // call the main movement routine
9426
2/2
✓ Branch 0 taken 15396 times.
✓ Branch 1 taken 6177406 times.
6192802 if(get_bit(quest_rules,qr_NEW_HERO_MOVEMENT2))
9427 {
9428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 if(premove())
9429 15396 movehero();
9430 15396 }
9431 6177406 else moveheroOld();
9432 6192802 }
9433
9434
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6418211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6418211 if(shield_forcedir > -1 && action != rafting)
9435 dir = shield_forcedir;
9436
9437
2/2
✓ Branch 0 taken 6390100 times.
✓ Branch 1 taken 28111 times.
6418211 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
9438 28111 set_respawn_point(false); //Keep the 'last safe location' updated!
9439
9440 // check for ladder removal
9441
2/2
✓ Branch 0 taken 712705 times.
✓ Branch 1 taken 5705506 times.
6418211 if(diagonalMovement)
9442 {
9443
2/2
✓ Branch 0 taken 712669 times.
✓ Branch 1 taken 36 times.
712705 if(ladderx+laddery)
9444 {
9445
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(ladderdir==up)
9446 {
9447 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9448 {
9449 reset_ladder();
9450 }
9451 }
9452 else
9453 {
9454
9/10
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 33 times.
36 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9455 {
9456 3 reset_ladder();
9457 3 }
9458 }
9459 36 }
9460 712705 }
9461 else
9462 {
9463
4/4
✓ Branch 0 taken 224933 times.
✓ Branch 1 taken 5480573 times.
✓ Branch 2 taken 121768 times.
✓ Branch 3 taken 103165 times.
5705506 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9464 {
9465 5602341 reset_ladder();
9466 5602341 }
9467 }
9468
9469
2/2
✓ Branch 0 taken 898 times.
✓ Branch 1 taken 6417313 times.
6418211 if(ilswim)
9470 898 landswim++;
9471 6417313 else landswim=0;
9472
9473
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6418209 times.
6418211 if(hopclk!=0xFF) ilswim=false;
9474
9475
3/4
✓ Branch 0 taken 13125 times.
✓ Branch 1 taken 6405086 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13125 times.
6418211 if((!loaded_guys) && (frame - newscr_clk >= 1))
9476 {
9477
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13112 times.
13125 if(tmpscr->room==rGANON)
9478 {
9479 13 ganon_intro();
9480 13 }
9481 else
9482 {
9483 13112 loadguys();
9484 }
9485 13125 }
9486
9487
2/2
✓ Branch 0 taken 13688 times.
✓ Branch 1 taken 6404523 times.
6418211 if(frame - newscr_clk >= 2)
9488 {
9489 6404523 loadenemies();
9490 6404523 }
9491
9492 // check lots of other things
9493 6418211 checkscroll();
9494
9495
6/8
✓ Branch 0 taken 6408509 times.
✓ Branch 1 taken 9702 times.
✓ Branch 2 taken 6407879 times.
✓ Branch 3 taken 630 times.
✓ Branch 4 taken 6407879 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6407879 times.
6418211 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9496 {
9497 6407879 checkspecial();
9498 6407879 checkitems();
9499 6407879 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9500
2/2
✓ Branch 0 taken 28612 times.
✓ Branch 1 taken 6379267 times.
6407879 if(get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
9501 {
9502 6379267 oldchecklockblock();
9503 6379267 oldcheckbosslockblock();
9504 6379267 }
9505
2/2
✓ Branch 0 taken 158279 times.
✓ Branch 1 taken 6249600 times.
6407879 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
9506 {
9507 6249600 oldcheckchest(cCHEST);
9508 6249600 oldcheckchest(cLOCKEDCHEST);
9509 6249600 oldcheckchest(cBOSSCHEST);
9510 6249600 }
9511 6407879 checkpushblock();
9512 6407879 checkswordtap();
9513
9514
2/2
✓ Branch 0 taken 4732 times.
✓ Branch 1 taken 6403147 times.
6407879 if(hookshot_frozen==false)
9515 {
9516 6403147 checkspecial2(&lsave);
9517 6403147 }
9518
9519
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 6407870 times.
6407879 if(action==won)
9520 {
9521 9 return true;
9522 }
9523 6407870 }
9524
9525 // Somehow Hero was displaced from the fairy flag...
9526
3/6
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 6401841 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16361 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6418202 if(fairyclk && action != freeze && action != sideswimfreeze)
9527 {
9528 fairyclk = holdclk = refill_why = 0;
9529 }
9530
9531
4/4
✓ Branch 0 taken 6418200 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 9978 times.
✓ Branch 3 taken 6408222 times.
6418202 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
9532 {
9533 9978 tmpscr->timedwarptics--;
9534
9535
2/2
✓ Branch 0 taken 9938 times.
✓ Branch 1 taken 40 times.
9978 if(tmpscr->timedwarptics==0)
9536 {
9537 40 activated_timed_warp=true;
9538
9539
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 3 times.
40 if(tmpscr->flags4 & fTIMEDDIRECT)
9540 {
9541 3 didpit=true;
9542 3 pitx=x;
9543 3 pity=y;
9544 3 }
9545
9546 40 int32_t index2 = 0;
9547
9548
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
9549
9550 40 sdir = dir;
9551 40 dowarp(1,index2);
9552 40 }
9553 9978 }
9554
9555 6418202 bool awarp = false;
9556 //!DIMI: Global Combo Effects (AUTO STUFF)
9557
2/2
✓ Branch 0 taken 292478 times.
✓ Branch 1 taken 6418202 times.
6710680 for(auto& p : slopes)
9558 {
9559 292478 slope_object& s = p.second;
9560 292478 s.updateslope(); //sets old x/y poses
9561 }
9562
2/2
✓ Branch 0 taken 6418201 times.
✓ Branch 1 taken 1129603174 times.
1136021375 for(int32_t i=0; i<176; ++i)
9563 {
9564
2/2
✓ Branch 0 taken 4795296 times.
✓ Branch 1 taken 4532798581 times.
4537593877 for(int32_t layer=0; layer<7; ++layer)
9565 {
9566
2/2
✓ Branch 0 taken 1129603174 times.
✓ Branch 1 taken 3403195407 times.
4532798581 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
9567 4532798581 newcombo const& cmb = combobuf[cid];
9568
9569
2/2
✓ Branch 0 taken 33567072 times.
✓ Branch 1 taken 4499231509 times.
4532798581 if(!get_bit(quest_rules,qr_AUTOCOMBO_ANY_LAYER))
9570 {
9571
2/2
✓ Branch 0 taken 1124807877 times.
✓ Branch 1 taken 3374423632 times.
4499231509 if(layer > 2) break;
9572
4/4
✓ Branch 0 taken 1124807877 times.
✓ Branch 1 taken 2249615755 times.
✓ Branch 2 taken 1101646453 times.
✓ Branch 3 taken 23161424 times.
3374423632 if (layer == 1 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_1)) continue;
9573
4/4
✓ Branch 0 taken 1124807877 times.
✓ Branch 1 taken 1147969302 times.
✓ Branch 2 taken 23161424 times.
✓ Branch 3 taken 1101646453 times.
2272777179 if (layer == 2 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_2)) continue;
9574 1171130726 }
9575 1204697798 int32_t ind=0;
9576
9577 //AUTOMATIC TRIGGER CODE
9578
2/2
✓ Branch 0 taken 1204683712 times.
✓ Branch 1 taken 14086 times.
1204697798 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9579 {
9580 14086 do_trigger_combo(layer, i);
9581 14086 }
9582
9583 //AUTO WARP CODE
9584
2/2
✓ Branch 0 taken 19463 times.
✓ Branch 1 taken 1204678335 times.
1204697798 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9585 {
9586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1204678335 times.
1204678335 if(cmb.type==cAWARPA)
9587 {
9588 awarp=true;
9589 ind=0;
9590 }
9591
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1204678334 times.
1204678335 else if(cmb.type==cAWARPB)
9592 {
9593 1 awarp=true;
9594 1 ind=1;
9595 1 }
9596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1204678334 times.
1204678334 else if(cmb.type==cAWARPC)
9597 {
9598 awarp=true;
9599 ind=2;
9600 }
9601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1204678334 times.
1204678334 else if(cmb.type==cAWARPD)
9602 {
9603 awarp=true;
9604 ind=3;
9605 }
9606
1/2
✓ Branch 0 taken 1204678334 times.
✗ Branch 1 not taken.
1204678334 else if(cmb.type==cAWARPR)
9607 {
9608 awarp=true;
9609 ind=zc_oldrand()%4;
9610 }
9611 1204678335 }
9612
2/2
✓ Branch 0 taken 1204697797 times.
✓ Branch 1 taken 1 times.
1204697798 if(awarp)
9613 {
9614
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags5&fDIRECTAWARP)
9615 {
9616 didpit=true;
9617 pitx=x;
9618 pity=y;
9619 }
9620
9621 1 sdir = dir;
9622 1 dowarp(1,ind);
9623 1 break;
9624 }
9625 1204697797 }
9626
2/2
✓ Branch 0 taken 1129603173 times.
✓ Branch 1 taken 1 times.
1129603174 if(awarp) break;
9627 1129603173 }
9628
9629 6418202 awarp=false;
9630
9631 6418202 word c = tmpscr->numFFC();
9632
2/2
✓ Branch 0 taken 6418185 times.
✓ Branch 1 taken 201251160 times.
207669345 for(word i=0; i<c; i++)
9633 {
9634 201251160 int32_t ind=0;
9635
9636 201251160 newcombo const& cmb = combobuf[tmpscr->ffcs[i].getData()];
9637
9638
1/2
✓ Branch 0 taken 201251160 times.
✗ Branch 1 not taken.
201251160 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9639 {
9640 do_trigger_combo_ffc(i);
9641 }
9642
9643
2/2
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 201247252 times.
201251160 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9644 {
9645
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 201247246 times.
201247252 if(cmb.type==cAWARPA)
9646 {
9647 6 awarp=true;
9648 6 ind=0;
9649 6 }
9650
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 201247239 times.
201247246 else if(cmb.type==cAWARPB)
9651 {
9652 7 awarp=true;
9653 7 ind=1;
9654 7 }
9655
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 201247238 times.
201247239 else if(cmb.type==cAWARPC)
9656 {
9657 1 awarp=true;
9658 1 ind=2;
9659 1 }
9660
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 201247235 times.
201247238 else if(cmb.type==cAWARPD)
9661 {
9662 3 awarp=true;
9663 3 ind=3;
9664 3 }
9665
1/2
✓ Branch 0 taken 201247235 times.
✗ Branch 1 not taken.
201247235 else if(cmb.type==cAWARPR)
9666 {
9667 awarp=true;
9668 ind=zc_oldrand()%4;
9669 }
9670 201247252 }
9671
9672
2/2
✓ Branch 0 taken 201251143 times.
✓ Branch 1 taken 17 times.
201251160 if(awarp)
9673 {
9674
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tmpscr->flags5&fDIRECTAWARP)
9675 {
9676 didpit=true;
9677 pitx=x;
9678 pity=y;
9679 }
9680
9681 17 sdir = dir;
9682 17 dowarp(1,ind);
9683 17 break;
9684 }
9685 201251143 }
9686 6418202 zfix dx, dy;
9687
7/8
✓ Branch 0 taken 261478 times.
✓ Branch 1 taken 6156724 times.
✓ Branch 2 taken 131408 times.
✓ Branch 3 taken 130070 times.
✓ Branch 4 taken 3777 times.
✓ Branch 5 taken 127631 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3777 times.
6418202 if (sideview_mode() && !on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && on_sideview_solid_oldpos(x, y,old_x,old_y, false, 2) && !toogam)
9688 {
9689
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 3723 times.
3777 if (slide_slope(this, dx, dy, slopeid))
9690 {
9691 3723 onplatid = 5;
9692
3/4
✓ Branch 0 taken 2066 times.
✓ Branch 1 taken 1657 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2066 times.
3723 if (dx || dy) push_move(dx, dy);
9693 3723 }
9694 3777 }
9695
2/2
✓ Branch 0 taken 6413623 times.
✓ Branch 1 taken 4579 times.
6418202 if (onplatid <= 0) slopeid = 0;
9696 4579 else --onplatid;
9697
2/2
✓ Branch 0 taken 4955671 times.
✓ Branch 1 taken 1462531 times.
6418202 bool onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9698
5/6
✓ Branch 0 taken 1460 times.
✓ Branch 1 taken 6418189 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1460 times.
✓ Branch 4 taken 1447 times.
✓ Branch 5 taken 6418202 times.
6419649 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
9699 {
9700
2/4
✓ Branch 0 taken 1447 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1447 times.
1447 if (check_slope(this, true) && !toogam)
9701 {
9702 1447 slope_info const& s = get_slope(this, true).get_info();
9703 1447 bool staircheck = false;
9704
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 1284 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 75 times.
1447 if (s.slope() != slopeid && slopeid) staircheck = true;
9705
2/2
✓ Branch 0 taken 1395 times.
✓ Branch 1 taken 52 times.
1447 if (onplatform) staircheck = true;
9706 1447 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
9707
9708
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 1060 times.
✓ Branch 2 taken 365 times.
✓ Branch 3 taken 22 times.
1447 if (dx || dy)
9709 {
9710 1425 int32_t pushret = push_move(dx,dy);
9711
2/2
✓ Branch 0 taken 1388 times.
✓ Branch 1 taken 37 times.
1425 onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9712
4/4
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 1268 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 73 times.
1425 if (s.slope() != slopeid && slopeid) staircheck = true;
9713
2/2
✓ Branch 0 taken 1393 times.
✓ Branch 1 taken 32 times.
1425 if (onplatform) staircheck = true;
9714
4/4
✓ Branch 0 taken 1347 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 1333 times.
1425 if(sideview_mode() && slopeid)
9715 1333 onplatid = 5;
9716
1/2
✓ Branch 0 taken 1425 times.
✗ Branch 1 not taken.
1425 if (pushret == 1)
9717 {
9718 dx = -1;
9719 dy = 0;
9720 slope_push_int(s, this, dx, dy, staircheck);
9721 push_move(dx,dy);
9722 }
9723
2/2
✓ Branch 0 taken 1407 times.
✓ Branch 1 taken 18 times.
1425 if (pushret == 2)
9724 {
9725 18 dx = 0;
9726 18 dy = -1;
9727 18 slope_push_int(s, this, dx, dy, staircheck);
9728 18 push_move(dx,dy);
9729 18 }
9730 1425 }
9731 1447 }
9732 1447 }
9733
9734
2/2
✓ Branch 0 taken 6417997 times.
✓ Branch 1 taken 205 times.
6418202 if(ffwarp)
9735 {
9736
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 126 times.
205 if(ffpit)
9737 {
9738 126 ffpit=false;
9739 126 didpit=true;
9740 126 pitx=x;
9741 126 pity=y;
9742 126 }
9743
9744 205 ffwarp=false;
9745 205 dowarp(1,0);
9746 205 }
9747
9748 //Hero->WarpEx
9749
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6418186 times.
6418202 if ( FFCore.warpex[wexActive] )
9750 {
9751 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
9752 16 FFCore.warpex[wexActive] = 0;
9753 16 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
9754
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 16 times.
160 for ( int32_t q = 0; q < wexActive; q++ )
9755 {
9756 144 temp_warpex[q] = FFCore.warpex[q];
9757 144 FFCore.warpex[q] = 0;
9758 144 }
9759 32 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
9760 16 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
9761 16 }
9762
9763 // walk through bombed doors and fake walls
9764 6418202 bool walk=false;
9765 6418202 int32_t dtype=dBOMBED;
9766
9767
2/2
✓ Branch 0 taken 6241929 times.
✓ Branch 1 taken 176273 times.
6418202 if(pushing>=24) dtype=dWALK;
9768
9769
16/18
✓ Branch 0 taken 3659598 times.
✓ Branch 1 taken 2758604 times.
✓ Branch 2 taken 3619787 times.
✓ Branch 3 taken 39811 times.
✓ Branch 4 taken 3619787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3614419 times.
✓ Branch 7 taken 5368 times.
✓ Branch 8 taken 3611844 times.
✓ Branch 9 taken 2575 times.
✓ Branch 10 taken 3611193 times.
✓ Branch 11 taken 651 times.
✓ Branch 12 taken 3601342 times.
✓ Branch 13 taken 9851 times.
✓ Branch 14 taken 3601342 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 101062 times.
✓ Branch 17 taken 3702404 times.
6418202 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
9770 {
9771
16/18
✓ Branch 0 taken 100684 times.
✓ Branch 1 taken 3601720 times.
✓ Branch 2 taken 590976 times.
✓ Branch 3 taken 3010744 times.
✓ Branch 4 taken 590861 times.
✓ Branch 5 taken 115 times.
✓ Branch 6 taken 590861 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 590861 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 109 times.
✓ Branch 12 taken 130662 times.
✓ Branch 13 taken 460314 times.
✓ Branch 14 taken 38152 times.
✓ Branch 15 taken 92510 times.
✓ Branch 16 taken 38016 times.
✓ Branch 17 taken 136 times.
3702404 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y<=32 && tmpscr->door[0]==dtype)
9772 {
9773 136 walk=true;
9774 136 dir=up;
9775 136 }
9776
9777
16/18
✓ Branch 0 taken 100684 times.
✓ Branch 1 taken 3601720 times.
✓ Branch 2 taken 388941 times.
✓ Branch 3 taken 3212779 times.
✓ Branch 4 taken 489459 times.
✓ Branch 5 taken 166 times.
✓ Branch 6 taken 489459 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 489459 times.
✓ Branch 10 taken 74 times.
✓ Branch 11 taken 92 times.
✓ Branch 12 taken 75655 times.
✓ Branch 13 taken 413970 times.
✓ Branch 14 taken 22498 times.
✓ Branch 15 taken 53157 times.
✓ Branch 16 taken 22383 times.
✓ Branch 17 taken 115 times.
3702404 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y>=128 && tmpscr->door[1]==dtype)
9778 {
9779 115 walk=true;
9780 115 dir=down;
9781 115 }
9782
9783
11/16
✓ Branch 0 taken 100684 times.
✓ Branch 1 taken 3601720 times.
✓ Branch 2 taken 59050 times.
✓ Branch 3 taken 3542670 times.
✓ Branch 4 taken 58672 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58672 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 58672 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 26325 times.
✓ Branch 13 taken 32347 times.
✓ Branch 14 taken 26224 times.
✓ Branch 15 taken 101 times.
3702404 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[2]==dtype)
9784 {
9785 101 walk=true;
9786 101 dir=left;
9787 101 }
9788
9789
11/16
✓ Branch 0 taken 3500658 times.
✓ Branch 1 taken 100684 times.
✓ Branch 2 taken 52160 times.
✓ Branch 3 taken 3448498 times.
✓ Branch 4 taken 72644 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 72644 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 72644 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 35229 times.
✓ Branch 13 taken 37415 times.
✓ Branch 14 taken 35114 times.
✓ Branch 15 taken 115 times.
3601342 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[3]==dtype)
9790 {
9791 115 walk=true;
9792 115 dir=right;
9793 115 }
9794 3521142 }
9795
9796
2/2
✓ Branch 0 taken 6438597 times.
✓ Branch 1 taken 467 times.
6439064 if(walk)
9797 {
9798 467 hclk=0;
9799 467 drawguys=false;
9800
9801
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 172 times.
467 if(dtype==dWALK)
9802 {
9803 172 sfx(tmpscr->secretsfx);
9804 172 }
9805
9806 467 action=none; FFCore.setHeroAction(none);
9807 467 attackclk = 0;
9808 467 stepforward(29, true);
9809 467 action=scrolling; FFCore.setHeroAction(scrolling);
9810 467 pushing=false;
9811 467 }
9812
9813
4/6
✓ Branch 0 taken 108798 times.
✓ Branch 1 taken 6330266 times.
✓ Branch 2 taken 108798 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 108798 times.
6439064 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
9814 {
9815
1/2
✓ Branch 0 taken 108798 times.
✗ Branch 1 not taken.
108798 if(heart_beep)
9816 {
9817 108798 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9818 108798 }
9819 else
9820 {
9821 if ( heart_beep_timer == -1 )
9822 {
9823 heart_beep_timer = 70;
9824 }
9825
9826 if ( heart_beep_timer > 0 )
9827 {
9828 --heart_beep_timer;
9829 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9830 }
9831 else
9832 {
9833 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9834 }
9835 }
9836 108798 }
9837 else
9838 {
9839
2/2
✓ Branch 0 taken 20864 times.
✓ Branch 1 taken 6309402 times.
6330266 if ( heart_beep_timer > -2 )
9840 {
9841 6309402 heart_beep_timer = -1;
9842 6309402 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9843 6309402 }
9844 }
9845
9846
2/2
✓ Branch 0 taken 6438299 times.
✓ Branch 1 taken 765 times.
6439064 if(rSbtn())
9847 {
9848 765 int32_t tmp_subscr_clk = frame;
9849
9850 765 int32_t save_type = 0;
9851
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
765 switch(lsave)
9852 {
9853 case 0:
9854 {
9855
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 716 times.
757 if( FFCore.runActiveSubscreenScriptEngine() )
9856 {
9857 41 break;
9858 }
9859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 else if ( !stopSubscreenFalling() )
9860 {
9861 716 conveyclk=3;
9862 716 dosubscr(&QMisc);
9863 716 newscr_clk += frame - tmp_subscr_clk;
9864 716 }
9865 716 break;
9866 }
9867
9868
9869 case 2:
9870 save_type = 1;
9871 [[fallthrough]];
9872 case 1:
9873
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
9874 7 trigger_save(combobuf[last_savepoint_id]);
9875 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
9876 7 break;
9877 }
9878 765 }
9879
9880
2/2
✓ Branch 0 taken 354161 times.
✓ Branch 1 taken 6084901 times.
6439062 if (!checkstab() )
9881 {
9882 /*
9883 for(int32_t q=0; q<176; q++)
9884 {
9885 set_bit(screengrid,q,0);
9886 }
9887
9888 for(int32_t q=0; q<MAXFFCS; q++)
9889 set_bit(ffcgrid, q, 0);
9890 */
9891 6084901 }
9892
9893 6439062 check_conveyor();
9894 6439062 PhantomsCleanup();
9895 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
9896
2/2
✓ Branch 0 taken 6373278 times.
✓ Branch 1 taken 65784 times.
6439062 if(attack==wHammer)
9897 {
9898
6/8
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 65043 times.
✓ Branch 2 taken 741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 741 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 739 times.
65784 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
9899 {
9900
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 162 times.
✓ Branch 3 taken 213 times.
✓ Branch 4 taken 247 times.
739 switch(dir) //Hero's dir
9901 {
9902 case up:
9903
5/10
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 117 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 117 times.
✗ Branch 9 not taken.
117 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
9904 117 break;
9905
9906 case down:
9907
5/10
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 162 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
9908 162 break;
9909
9910 case left:
9911
5/10
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 213 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 213 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 213 times.
✗ Branch 9 not taken.
213 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
9912 213 break;
9913
9914 case right:
9915
5/10
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 247 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 247 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 247 times.
✗ Branch 9 not taken.
247 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
9916 247 break;
9917 }
9918
9919 739 }
9920 65784 }
9921
9922 6439062 handleSpotlights();
9923
9924
2/2
✓ Branch 0 taken 6438736 times.
✓ Branch 1 taken 326 times.
6439062 if(getOnSideviewLadder())
9925 {
9926
5/8
✓ Branch 0 taken 319 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 319 times.
326 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
9927 {
9928 7 setOnSideviewLadder(false);
9929 7 }
9930
4/8
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 213 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
319 else if(CANFORCEFACEUP)
9931 {
9932 106 setDir(up);
9933 106 }
9934 326 }
9935
2/2
✓ Branch 0 taken 215765 times.
✓ Branch 1 taken 6223297 times.
6439062 if (justmoved > 0) --justmoved;
9936
9937 6439062 return false;
9938 6439419 }
9939
9940 9044 bool HeroClass::push_pixel(zfix dx, zfix dy)
9941 {
9942
2/4
✓ Branch 0 taken 9044 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9044 times.
✗ Branch 3 not taken.
9044 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
9943
3/4
✓ Branch 0 taken 4371 times.
✓ Branch 1 taken 4673 times.
✓ Branch 2 taken 4371 times.
✗ Branch 3 not taken.
9044 if(dx && dy)
9944 {
9945 bool r = push_pixel(0,dy);
9946 bool r2 = push_pixel(dx,0);
9947 return r && r2;
9948 }
9949
2/2
✓ Branch 0 taken 3684 times.
✓ Branch 1 taken 5360 times.
9044 if(dx < 0)
9950 {
9951
1/2
✓ Branch 0 taken 3684 times.
✗ Branch 1 not taken.
7368 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
9952
1/2
✓ Branch 0 taken 3684 times.
✗ Branch 1 not taken.
3684 || solpush_walkflag(x+dx,y+8,1,this)
9953
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3684 times.
✓ Branch 2 taken 3228 times.
✓ Branch 3 taken 456 times.
3684 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
9954 {
9955 3684 x += dx;
9956 3684 return true;
9957 }
9958 return false;
9959 }
9960
2/2
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 4673 times.
5360 else if(dx > 0)
9961 {
9962
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
1374 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
9963
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 || solpush_walkflag(x+15+dx,y+8,1,this)
9964
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 235 times.
✓ Branch 3 taken 452 times.
687 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
9965 {
9966 687 x += dx;
9967 687 return true;
9968 }
9969 return false;
9970 }
9971
2/2
✓ Branch 0 taken 2484 times.
✓ Branch 1 taken 2189 times.
4673 else if(dy < 0)
9972 {
9973
1/2
✓ Branch 0 taken 2484 times.
✗ Branch 1 not taken.
4968 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
9974
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2484 times.
✓ Branch 2 taken 2257 times.
✓ Branch 3 taken 227 times.
2484 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
9975 {
9976 2484 y += dy;
9977 2484 return true;
9978 }
9979 return false;
9980 }
9981
1/2
✓ Branch 0 taken 2189 times.
✗ Branch 1 not taken.
2189 else if(dy > 0)
9982 {
9983
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 21 times.
4357 if(!(solpush_walkflag(x,y+15+dy,2,this)
9984
4/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 2168 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1866 times.
2189 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
9985 {
9986 2168 y += dy;
9987 2168 return true;
9988 }
9989 21 return false;
9990 }
9991 return false;
9992 9044 }
9993 4802 int32_t HeroClass::push_move(zfix dx, zfix dy)
9994 {
9995 4802 int32_t ret = 0;
9996
4/4
✓ Branch 0 taken 4371 times.
✓ Branch 1 taken 6234 times.
✓ Branch 2 taken 4802 times.
✓ Branch 3 taken 5803 times.
10605 while(dx || dy)
9997 {
9998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5803 times.
5803 if(check_pitslide() != -1)
9999 break;
10000
2/2
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 4673 times.
5803 if(dy)
10001 {
10002
2/2
✓ Branch 0 taken 2747 times.
✓ Branch 1 taken 1926 times.
4673 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
10003 4673 dy -= cy;
10004
2/2
✓ Branch 0 taken 4652 times.
✓ Branch 1 taken 21 times.
4673 if(!push_pixel(0,cy))
10005 {
10006 21 dy = 0;
10007 21 ret |= 2;
10008 21 }
10009 4673 }
10010
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 4371 times.
5803 if(dx)
10011 {
10012
2/2
✓ Branch 0 taken 1673 times.
✓ Branch 1 taken 2698 times.
4371 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
10013 4371 dx -= cx;
10014
1/2
✓ Branch 0 taken 4371 times.
✗ Branch 1 not taken.
4371 if(!push_pixel(cx,0))
10015 {
10016 dx = 0;
10017 ret |= 1;
10018 }
10019 4371 }
10020 }
10021 4802 return ret;
10022 }
10023
10024 6418492 bool HeroClass::setSolid(bool set)
10025 {
10026
1/2
✓ Branch 0 taken 6418492 times.
✗ Branch 1 not taken.
6418492 bool actual = set && !toogam; //not solid when noclipping
10027 6418492 bool ret = solid_object::setSolid(actual);
10028 6418492 solid = set;
10029 6418492 return ret;
10030 }
10031
10032 9441 void HeroClass::solid_push(solid_object* obj)
10033 {
10034
1/2
✓ Branch 0 taken 9441 times.
✗ Branch 1 not taken.
9441 if(obj == this) return; //can't push self
10035
10036 9441 zfix dx, dy;
10037 9441 int32_t hdir = -1;
10038 9441 solid_push_int(obj,dx,dy,hdir);
10039
10040
4/4
✓ Branch 0 taken 8382 times.
✓ Branch 1 taken 1059 times.
✓ Branch 2 taken 7739 times.
✓ Branch 3 taken 643 times.
9441 if(!dx && !dy) return;
10041
10042 1702 obj->doContactDamage(hdir);
10043
10044 1702 bool t = obj->getTempNonsolid();
10045 1702 obj->setTempNonsolid(true);
10046
10047 1702 push_move(dx,dy);
10048
10049 1702 obj->setTempNonsolid(t);
10050 9441 }
10051
10052 // A routine used exclusively by startwpn,
10053 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10054 733 void HeroClass::deselectbombs(int32_t super)
10055 {
10056
6/10
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 721 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 721 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 721 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 721 times.
733 if ( get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10057
2/6
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
721 if(getItemFamily(itemsbuf,Bwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10058 {
10059
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
721 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10060 721 Bwpn = Bweapon(temp);
10061 721 directItemB = directItem;
10062 721 game->bwpn = temp;
10063 721 }
10064
10065 else if (getItemFamily(itemsbuf,Xwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10066 {
10067 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10068 Xwpn = Bweapon(temp);
10069 directItemX = directItem;
10070 game->xwpn = temp;
10071 }
10072 else if (getItemFamily(itemsbuf,Ywpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10073 {
10074 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
10075 Ywpn = Bweapon(temp);
10076 directItemY = directItem;
10077 game->ywpn = temp;
10078 }
10079 else
10080 {
10081 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10082 Awpn = Bweapon(temp);
10083 directItemA = directItem;
10084 game->awpn = temp;
10085 }
10086 733 }
10087
10088 int32_t potion_life=0;
10089 int32_t potion_magic=0;
10090
10091 6193541 bool HeroClass::onWater(bool drownonly)
10092 {
10093 6193541 int32_t water = 0;
10094 6193541 int32_t types[4] = {0};
10095 6193541 int32_t x1 = x+4, x2 = x+11,
10096 6193541 y1 = y+9, y2 = y+15;
10097
2/2
✓ Branch 0 taken 241122 times.
✓ Branch 1 taken 5952419 times.
6193541 if (get_bit(quest_rules, qr_SMARTER_WATER))
10098 {
10099
4/4
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 239503 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1314 times.
242439 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10100
2/2
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 156 times.
1619 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10101
2/2
✓ Branch 0 taken 1317 times.
✓ Branch 1 taken 146 times.
1463 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10102 1317 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10103 241122 }
10104 else
10105 {
10106 5952419 types[0] = COMBOTYPE(x1,y1);
10107
10108
2/2
✓ Branch 0 taken 14829 times.
✓ Branch 1 taken 5937590 times.
5952419 if(MAPFFCOMBO(x1,y1))
10109 14829 types[0] = FFCOMBOTYPE(x1,y1);
10110
10111 5952419 types[1] = COMBOTYPE(x1,y2);
10112
10113
2/2
✓ Branch 0 taken 13914 times.
✓ Branch 1 taken 5938505 times.
5952419 if(MAPFFCOMBO(x1,y2))
10114 13914 types[1] = FFCOMBOTYPE(x1,y2);
10115
10116 5952419 types[2] = COMBOTYPE(x2,y1);
10117
10118
2/2
✓ Branch 0 taken 15061 times.
✓ Branch 1 taken 5937358 times.
5952419 if(MAPFFCOMBO(x2,y1))
10119 15061 types[2] = FFCOMBOTYPE(x2,y1);
10120
10121 5952419 types[3] = COMBOTYPE(x2,y2);
10122
10123
2/2
✓ Branch 0 taken 14121 times.
✓ Branch 1 taken 5938298 times.
5952419 if(MAPFFCOMBO(x2,y2))
10124 14121 types[3] = FFCOMBOTYPE(x2,y2);
10125
10126 5952419 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10127
2/2
✓ Branch 0 taken 14660 times.
✓ Branch 1 taken 5937759 times.
5952419 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10128 14660 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10129
10130
5/6
✓ Branch 0 taken 129959 times.
✓ Branch 1 taken 5822460 times.
✓ Branch 2 taken 122938 times.
✓ Branch 3 taken 7021 times.
✓ Branch 4 taken 116653 times.
✗ Branch 5 not taken.
6069072 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10131
4/4
✓ Branch 0 taken 116788 times.
✓ Branch 1 taken 6150 times.
✓ Branch 2 taken 116653 times.
✓ Branch 3 taken 135 times.
122938 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10132 116653 water = typec;
10133 }
10134
2/2
✓ Branch 0 taken 6075574 times.
✓ Branch 1 taken 117967 times.
6193541 if(water > 0)
10135 {
10136
1/2
✓ Branch 0 taken 117967 times.
✗ Branch 1 not taken.
117967 if(!drownonly) return true;
10137
4/8
✓ Branch 0 taken 67284 times.
✓ Branch 1 taken 50683 times.
✓ Branch 2 taken 67284 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 67284 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
117967 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10138 {
10139 50683 return true;
10140 }
10141 67284 }
10142 6142858 return false;
10143 6193541 }
10144
10145 bool HeroClass::mirrorBonk()
10146 {
10147 zfix tx = x, ty = y, tz = z;
10148 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10149 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10150 execute(info);
10151 bool fail = info.isUnwalkable();
10152
10153 if(!fail) //not solid, but check for water/pits...
10154 {
10155 if(onWater(true))
10156 fail = true;
10157 if(pitslide() || fallclk)
10158 fail = true;
10159 fallclk = 0;
10160 }
10161 x = tx; y = ty; z = tz;
10162 return fail;
10163 }
10164
10165 void HeroClass::doMirror(int32_t mirrorid)
10166 {
10167 if(z > 0 || fakez > 0) return; //No mirror in air
10168 if(mirrorid < 0)
10169 mirrorid = current_item_id(itype_mirror);
10170 if(mirrorid < 0) return;
10171
10172 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10173 {
10174 item_error();
10175 return;
10176 }
10177 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10178 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10179 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10180 for(auto pos : posarr)
10181 {
10182 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10183 {
10184 item_error();
10185 return;
10186 }
10187 }
10188
10189 itemdata const& mirror = itemsbuf[mirrorid];
10190 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10191 {
10192 paymagiccost(mirrorid);
10193 if(mirror.usesound2) sfx(mirror.usesound2);
10194
10195 doWarpEffect(mirror.misc2, true);
10196 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10197 {
10198 Quit = qCONT;
10199 skipcont = 1;
10200 }
10201 else //Act as Divine Escape
10202 {
10203 int32_t div_prot_temp=div_prot_item;
10204 restart_level();
10205 div_prot_item=div_prot_temp;
10206 magicitem=-1;
10207 magiccastclk=0;
10208 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10209 }
10210 }
10211 else
10212 {
10213 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10214 int32_t offscr = currscr - DMaps[currdmap].xoff;
10215 if(destdmap < 0)
10216 return;
10217 int32_t destscr = DMaps[destdmap].xoff + offscr;
10218 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10219 return;
10220 paymagiccost(mirrorid);
10221
10222 //Store some values to restore if 'warp fails'
10223 int32_t tLastEntrance = lastentrance,
10224 tLastEntranceDMap = lastentrance_dmap,
10225 tContScr = game->get_continue_scrn(),
10226 tContDMap = game->get_continue_dmap(),
10227 tPortalDMap = game->saved_mirror_portal.srcdmap;
10228 int32_t sourcescr = currscr, sourcedmap = currdmap;
10229 zfix tx = x, ty = y, tz = z;
10230 game->saved_mirror_portal.srcdmap = -1;
10231 action = none; FFCore.setHeroAction(none);
10232
10233 //Warp to new dmap
10234 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10235 mirror.usesound, 0, -1);
10236
10237 //Check for valid landing location
10238 if(mirrorBonk()) //Invalid landing, warp back!
10239 {
10240 action = none; FFCore.setHeroAction(none);
10241 lastentrance = tLastEntrance;
10242 lastentrance_dmap = tLastEntranceDMap;
10243 game->set_continue_scrn(tContScr);
10244 game->set_continue_dmap(tContDMap);
10245 x = tx;
10246 y = ty;
10247 z = tz;
10248 game->saved_mirror_portal.srcdmap = tPortalDMap;
10249 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10250 mirror.usesound, 0, -1);
10251 }
10252 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10253 {
10254 //Place the portal
10255 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10256 //Since it was placed after loading this screen, load the portal object now
10257 game->load_portal();
10258 //Don't immediately trigger the warp back
10259 mirror_portal.prox_active = false;
10260
10261 //Set continue point
10262 if(currdmap != game->get_continue_dmap())
10263 {
10264 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10265 }
10266 game->set_continue_dmap(currdmap);
10267 lastentrance_dmap = currdmap;
10268 lastentrance = game->get_continue_scrn();
10269 }
10270 }
10271 }
10272
10273 6418211 void HeroClass::handle_passive_buttons()
10274 {
10275 6418211 do_liftglove(-1,true);
10276 6418211 do_jump(-1,true);
10277 6418211 }
10278
10279 static bool did_passive_jump = false;
10280 6418303 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10281 {
10282
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 6418211 times.
6418303 if(passive) did_passive_jump = false;
10283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 else if(did_passive_jump) return false; //don't jump twice in the same frame
10284
10285
2/2
✓ Branch 0 taken 224762 times.
✓ Branch 1 taken 6193541 times.
6418303 if(nomove_action(action)) return false; //can't jump while ex. drowning
10286
2/2
✓ Branch 0 taken 50683 times.
✓ Branch 1 taken 6142858 times.
6193541 if(onWater(true)) return false; //Don't allow jumping off of water frame-perfectly...
10287
10288
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 6142766 times.
6142858 if(jumpid < 0)
10289 6142766 jumpid = current_item_id(itype_rocs,true,true);
10290
10291
2/2
✓ Branch 0 taken 5950524 times.
✓ Branch 1 taken 192334 times.
6142858 if(unsigned(jumpid) >= MAXITEMS) return false;
10292
4/4
✓ Branch 0 taken 192223 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 1411 times.
✓ Branch 3 taken 190812 times.
192334 if(inlikelike || charging) return false;
10293
1/2
✓ Branch 0 taken 190812 times.
✗ Branch 1 not taken.
190812 if(!checkitem_jinx(jumpid)) return false;
10294
10295 190812 itemdata const& itm = itemsbuf[jumpid];
10296
10297 190812 bool standing = isStanding(true);
10298
3/4
✓ Branch 0 taken 187766 times.
✓ Branch 1 taken 3046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3046 times.
190812 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10299
4/6
✓ Branch 0 taken 190812 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3046 times.
✓ Branch 3 taken 187766 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3046 times.
190812 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10300
3/4
✓ Branch 0 taken 185964 times.
✓ Branch 1 taken 1802 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 185964 times.
187766 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10301 {
10302 1802 item_error();
10303 1802 return false;
10304 }
10305
10306 185964 byte intbtn = byte(itm.misc2&0xFF);
10307
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 185885 times.
185964 if(passive)
10308 {
10309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185885 times.
185885 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10310 185885 return false; //not pressed
10311 }
10312
10313 79 paymagiccost(jumpid);
10314
10315
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!standing)
10316 {
10317 ++extra_jump_count;
10318 fall = 0;
10319 fakefall = 0;
10320 if(hoverclk > 0)
10321 hoverclk = -hoverclk;
10322 }
10323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(itm.flags & ITEM_FLAG1)
10324 setFall(fall - itm.power);
10325 79 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10326 79 coyotetime = 65535; //jumped, so no coyotetime
10327 79 setOnSideviewLadder(false);
10328
10329 // Reset the ladder, unless on an unwalkable combo
10330
3/10
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 79 times.
✗ Branch 9 not taken.
79 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
10331 reset_ladder();
10332
10333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(itm.usesound)
10334 79 sfx(itm.usesound,pan(x.getInt()));
10335
10336
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(passive)
10337 {
10338 did_passive_jump = true;
10339 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10340 }
10341 79 return true;
10342 6418303 }
10343 863 void HeroClass::drop_liftwpn()
10344 {
10345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 863 times.
863 if(!lift_wpn) return;
10346
10347 handle_lift(false); //sets position properly, accounting for large weapons
10348 auto liftid = current_item_id(itype_liftglove,true,true);
10349 itemdata const& glove = itemsbuf[liftid];
10350 auto lheight = liftheight+z+fakez;
10351 if(glove.flags & ITEM_FLAG1)
10352 {
10353 lift_wpn->z = 0;
10354 lift_wpn->fakez = lheight;
10355 }
10356 else lift_wpn->z = lheight;
10357 lift_wpn->dir = dir;
10358 lift_wpn->step = 0;
10359 lift_wpn->fakefall = 0;
10360 lift_wpn->fall = 0;
10361 if(glove.flags & ITEM_FLAG1)
10362 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10363 else
10364 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10365 Lwpns.add(lift_wpn);
10366 lift_wpn = nullptr;
10367 863 }
10368 6418211 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10369 {
10370
1/2
✓ Branch 0 taken 6418211 times.
✗ Branch 1 not taken.
6418211 if(liftid < 0)
10371 6418211 liftid = current_item_id(itype_liftglove,true,true);
10372
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 6408400 times.
6418211 if(!can_lift(liftid)) return;
10373 9811 itemdata const& glove = itemsbuf[liftid];
10374 9811 byte intbtn = byte(glove.misc1&0xFF);
10375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9811 times.
9811 if(passive)
10376 {
10377
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 9759 times.
9811 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10378 9759 return; //not pressed
10379 52 }
10380
10381 52 bool had_weapon = lift_wpn;
10382
10383
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
91 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10384
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 2 times.
41 (checkbunny(liftid) && checkmagiccost(liftid))))
10385 {
10386 2 item_error();
10387 2 return;
10388 }
10389
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
50 if(glove.script!=0 && (item_doscript[liftid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10390 return;
10391
10392 50 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10393
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(glove.script)
10394 {
10395 if(!paidmagic)
10396 {
10397 paidmagic = true;
10398 paymagiccost(liftid);
10399 }
10400
10401 ri = &(itemScriptData[liftid]);
10402 for ( int32_t q = 0; q < 1024; q++ )
10403 item_stack[liftid][q] = 0xFFFF;
10404 ri->Clear();
10405 item_doscript[liftid] = 1;
10406 itemscriptInitialised[liftid] = 0;
10407 ZScriptVersion::RunScript(SCRIPT_ITEM, glove.script, liftid);
10408
10409 bool has_weapon = lift_wpn;
10410 if(has_weapon != had_weapon) //Item action script changed the lift information
10411 {
10412 if(passive)
10413 {
10414 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10415 }
10416 return;
10417 }
10418 }
10419
10420
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 39 times.
50 if(lift_wpn)
10421 {
10422
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!paidmagic)
10423 {
10424 paidmagic = true;
10425 paymagiccost(liftid);
10426 }
10427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!liftclk)
10428 {
10429 //Throw the weapon!
10430 //hero's direction and position
10431 11 handle_lift(false); //sets position properly, accounting for large weapons
10432 11 auto lheight = liftheight+z+fakez;
10433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(glove.flags & ITEM_FLAG1)
10434 {
10435 lift_wpn->z = 0;
10436 lift_wpn->fakez = lheight;
10437 }
10438 11 else lift_wpn->z = lheight;
10439 11 lift_wpn->dir = dir;
10440 //Configured throw speed in both axes
10441 11 lift_wpn->step = zfix(glove.misc2)/100;
10442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(glove.flags & ITEM_FLAG1)
10443 {
10444 lift_wpn->fakefall = -glove.misc3;
10445 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10446 }
10447 else
10448 {
10449 11 lift_wpn->fall = -glove.misc3;
10450 11 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10451 }
10452 11 Lwpns.add(lift_wpn);
10453 11 lift_wpn = nullptr;
10454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(glove.usesound2)
10455 11 sfx(glove.usesound2,pan(int32_t(x)));
10456 11 }
10457
10458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(passive)
10459 {
10460 11 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10461 11 }
10462 11 return;
10463 }
10464
10465 39 bool lifted = false;
10466 //Check for a liftable weapon
10467 //if(!lifted)
10468 {
10469 39 zfix hx, hy, hw, hh;
10470
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 13 times.
39 switch(dir)
10471 {
10472 case up:
10473 15 hx = x;
10474 15 hy = y-8;
10475 15 hw = 16;
10476 15 hh = bigHitbox ? 8 : 16;
10477 15 break;
10478 case down:
10479 7 hx = x;
10480 7 hy = y+16;
10481 7 hw = 16;
10482 7 hh = 8;
10483 7 break;
10484 case left:
10485 4 hx = x-8;
10486 4 hy = y;
10487 4 hw = 8;
10488 4 hh = 16;
10489 4 break;
10490 case right:
10491 13 hx = x+16;
10492 13 hy = y;
10493 13 hw = 8;
10494 13 hh = 16;
10495 13 break;
10496 }
10497
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 16 times.
55 for(int32_t q = 0; q < Lwpns.Count(); ++q)
10498 {
10499 16 weapon* w = (weapon*)Lwpns.spr(q);
10500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 switch(w->id)
10501 {
10502 case wLitBomb:
10503 case wLitSBomb:
10504 if(w->parentitem>=0)
10505 {
10506 itemdata const& parent = itemsbuf[w->parentitem];
10507 if((parent.family==itype_bomb || parent.family==itype_sbomb)
10508 && (parent.misc4 && parent.misc4 <= glove.fam_type))
10509 {
10510 if(!w->hit(hx,hy,0,hw,hh,1))
10511 continue;
10512 lift(w, parent.misc5, parent.misc6);
10513 Lwpns.remove(w);
10514 lifted = true;
10515 break;
10516 }
10517 }
10518 break;
10519 }
10520
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(lifted) break;
10521 16 }
10522 }
10523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(!lifted) //Check for a liftable combo
10524 {
10525 39 zfix bx, by;
10526 39 zfix bx2, by2;
10527
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 13 times.
39 switch(dir)
10528 {
10529 case up:
10530 15 by = y + (bigHitbox ? -2 : 6);
10531 15 by2 = by;
10532 15 bx = x + 4;
10533 15 bx2 = bx + 8;
10534 15 break;
10535 case down:
10536 7 by = y + 17;
10537 7 by2 = by;
10538 7 bx = x + 4;
10539 7 bx2 = bx + 8;
10540 7 break;
10541 case left:
10542 4 by = y + (bigHitbox ? 0 : 8);
10543 4 by2 = y + 8;
10544 4 bx = x - 2;
10545 4 bx2 = x - 2;
10546 4 break;
10547 case right:
10548 13 by = y + (bigHitbox ? 0 : 8);
10549 13 by2 = y + 8;
10550 13 bx = x + 17;
10551 13 bx2 = x + 17;
10552 13 break;
10553 }
10554 39 int32_t pos = COMBOPOS_B(bx,by);
10555 39 int32_t pos2 = COMBOPOS_B(bx2,by2);
10556 39 int32_t foundpos = -1;
10557
10558
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 269 times.
297 for(auto lyr = 6; lyr >= 0; --lyr)
10559 {
10560 269 mapscr* scr = FFCore.tempScreens[lyr];
10561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 269 times.
269 if(pos > -1)
10562 {
10563 269 newcombo const& cmb = combobuf[scr->data[pos]];
10564
2/2
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 11 times.
269 if(cmb.liftflags & LF_LIFTABLE)
10565 {
10566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(do_lift_combo(lyr,pos,liftid))
10567 {
10568 11 lifted = true;
10569 11 break;
10570 }
10571 }
10572 258 }
10573
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 181 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
258 if(pos != pos2 && pos2 > -1)
10574 {
10575 77 newcombo const& cmb2 = combobuf[scr->data[pos2]];
10576
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(cmb2.liftflags & LF_LIFTABLE)
10577 {
10578 if(do_lift_combo(lyr,pos2,liftid))
10579 {
10580 lifted = true;
10581 break;
10582 }
10583 }
10584 77 }
10585 258 }
10586 39 }
10587
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 28 times.
39 if(!lifted) return;
10588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!paidmagic)
10589 {
10590 11 paidmagic = true;
10591 11 paymagiccost(liftid);
10592 11 }
10593 11 set_liftflags(liftid);
10594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(passive)
10595 11 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10596 11 return;
10597 6418211 }
10598 947 void HeroClass::handle_lift(bool dec)
10599 {
10600
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(lift_wpn)
10601 947 lift_wpn->fakez = 0;
10602 else liftclk = 0;
10603
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 218 times.
947 if(liftclk <= (dec?1:0))
10604 {
10605 729 liftclk = 0;
10606 729 tliftclk = 0;
10607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 729 times.
729 if(lift_wpn)
10608 {
10609
2/4
✓ Branch 0 taken 729 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 729 times.
729 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
10610 {
10611 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
10612 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
10613 }
10614 else
10615 {
10616 729 lift_wpn->x = x;
10617 729 lift_wpn->y = y;
10618 }
10619 729 lift_wpn->z = liftheight;
10620 729 }
10621
2/2
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 11 times.
729 if(action == lifting)
10622 {
10623 11 action = none; FFCore.setHeroAction(none);
10624 11 }
10625 729 return;
10626 }
10627
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 109 times.
218 if(dec) --liftclk;
10628 double xdist, ydist;
10629 218 double perc = (liftclk/double(tliftclk));
10630
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 70 times.
218 switch(dir)
10631 {
10632 case up:
10633 {
10634 14 xdist = 0;
10635 14 ydist = -16;
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(lift_wpn->txsz > 1)
10637 {
10638 xdist = -((lift_wpn->txsz*8)-8);
10639 }
10640 14 else xdist = 0;
10641
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(lift_wpn->tysz > 1)
10642 {
10643 ydist = -(lift_wpn->tysz*16);
10644 }
10645 14 ydist *= perc;
10646 14 break;
10647 }
10648 case down:
10649 {
10650 74 xdist = 0;
10651 74 ydist = 16;
10652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(lift_wpn->txsz > 1)
10653 {
10654 xdist = -((lift_wpn->txsz*8)-8);
10655 }
10656 74 else xdist = 0;
10657 74 ydist *= perc;
10658 74 break;
10659 }
10660 case left:
10661 {
10662 60 xdist = -16;
10663 60 ydist = 0;
10664
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(lift_wpn->txsz > 1)
10665 {
10666 xdist = -(lift_wpn->txsz*16);
10667 }
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(lift_wpn->tysz > 1)
10669 {
10670 ydist = -((lift_wpn->tysz*8)-8);
10671 }
10672 60 else ydist = 0;
10673 60 xdist *= perc;
10674 60 break;
10675 }
10676 case right:
10677 {
10678 70 xdist = 16;
10679 70 ydist = 0;
10680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(lift_wpn->tysz > 1)
10681 {
10682 ydist = -((lift_wpn->tysz*8)-8);
10683 }
10684 70 else ydist = 0;
10685 70 xdist *= perc;
10686 70 break;
10687 }
10688 }
10689
10690 218 lift_wpn->x = x + xdist;
10691 218 lift_wpn->y = y + ydist;
10692 218 lift_wpn->z = liftheight*(1.0-perc);
10693 947 }
10694 6418222 bool HeroClass::can_lift(int32_t gloveid)
10695 {
10696
2/2
✓ Branch 0 taken 6407256 times.
✓ Branch 1 taken 10966 times.
6418222 if(unsigned(gloveid) >= MAXITEMS) return false;
10697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10966 times.
10966 if(lstunclock) return false;
10698
1/2
✓ Branch 0 taken 10966 times.
✗ Branch 1 not taken.
10966 if(!checkitem_jinx(gloveid)) return false;
10699 10966 itemdata const& glove = itemsbuf[gloveid];
10700
2/3
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 9822 times.
✗ Branch 2 not taken.
10966 switch(action)
10701 {
10702 case none: case walking:
10703 9822 break;
10704
10705 case swimming:
10706 if(glove.flags & ITEM_FLAG2)
10707 break;
10708 return false;
10709
10710 default:
10711 1144 return false;
10712 }
10713 9822 return true;
10714 6418222 }
10715 11 void HeroClass::lift(weapon* w, byte timer, zfix height)
10716 {
10717 11 lift_wpn = w;
10718 11 liftclk = timer;
10719 11 tliftclk = timer;
10720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(height < 0)
10721 liftheight = 0;
10722 11 else liftheight = height;
10723 11 }
10724
10725 1 void HeroClass::doSwitchHook(byte style)
10726 {
10727 1 hs_switcher = true;
10728 1 pull_hero = true;
10729 //{ Load hook weapons, set them to obey special drawing
10730 1 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
10731 1 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
10732
10733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w)
10734 1 w->switch_hooked = true;
10735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hw)
10736 1 hw->switch_hooked = true;
10737
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
10738 {
10739 5 chainlinks.spr(j)->switch_hooked = true;
10740 5 }
10741 //}
10742
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hooked_combopos > -1)
10743 {
10744 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
10745 hooked_layerbits = 0;
10746 for(auto q = 0; q < 7; ++q)
10747 hooked_undercombos[q] = -1;
10748 uint16_t plpos = COMBOPOS(x+8,y+8);
10749 for(auto q = max_layer; q > -1; --q)
10750 {
10751 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
10752 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
10753 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
10754 fl2 = FFCore.tempScreens[q]->sflag[plpos];
10755 bool isPush = false;
10756 if(isSwitchHookable(cmb))
10757 {
10758 if(cmb.type == cSWITCHHOOK)
10759 {
10760 uint16_t plpos = COMBOPOS(x+8,y+8);
10761 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
10762 continue; //don't swap with non-zero combo
10763 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
10764 continue; //too low a switchhook level
10765 hooked_layerbits |= 1<<q; //Swapping
10766 if(cmb.usrflags&cflag3)
10767 {
10768 if(cmb.usrflags&cflag6)
10769 {
10770 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10771 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10772 }
10773 else
10774 {
10775 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10776 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10777 }
10778 }
10779 else
10780 {
10781 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10782 if(cmb.usrflags&cflag7) //counts as 'pushblock'
10783 isPush = true;
10784 }
10785 }
10786 else if(isCuttableType(cmb.type))
10787 {
10788 if(isCuttableNextType(cmb.type))
10789 {
10790 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10791 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10792 }
10793 else
10794 {
10795 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10796 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10797 }
10798 hooked_layerbits |= 1<<q; //Swapping
10799 }
10800 else
10801 {
10802 hooked_layerbits |= 1<<q; //Swapping
10803 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10804 }
10805 }
10806 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
10807 {
10808 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
10809 && hasMainGuy())
10810 {
10811 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
10812 continue;
10813 }
10814 if(fl1 == mfPUSHED)
10815 {
10816 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
10817 continue;
10818 }
10819 if(!isPush) switch(fl1)
10820 {
10821 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10822 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10823 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10824 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10825 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10826 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10827 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10828 isPush = true;
10829 }
10830 if(!isPush) switch(cmb.flag)
10831 {
10832 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10833 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10834 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10835 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10836 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10837 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10838 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10839 isPush = true;
10840 }
10841 if(isPush) //Check for block holes / triggers
10842 {
10843 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
10844 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
10845 {
10846 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10847 }
10848 else if(!get_bit(quest_rules, qr_BLOCKHOLE_SAME_ONLY))
10849 {
10850 auto maxLayer = get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
10851 for(auto lyr = 0; lyr < maxLayer; ++lyr)
10852 {
10853 if(lyr == q) continue;
10854 switch(FFCore.tempScreens[q]->sflag[plpos])
10855 {
10856 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10857 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10858 lyr=7;
10859 break;
10860 }
10861 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
10862 {
10863 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10864 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10865 lyr=7;
10866 break;
10867 }
10868 }
10869 }
10870 }
10871 }
10872 }
10873 }
10874 1 switch_hooked = true;
10875 1 switchhookstyle = style;
10876
1/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 switch(style)
10877 {
10878 default: case swPOOF:
10879 {
10880 1 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
10881
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
10882
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(x, y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1)
10884 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object)
10886
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(switching_object->x, switching_object->y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10887 1 break;
10888 }
10889 case swFLICKER:
10890 {
10891 switchhookmaxtime = switchhookclk = 64;
10892 break;
10893 }
10894 case swRISE:
10895 {
10896 switchhookmaxtime = switchhookclk = 64;
10897 break;
10898 }
10899 }
10900 1 }
10901
10902 28432 bool HeroClass::startwpn(int32_t itemid)
10903 {
10904
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 28167 times.
28432 if(itemid < 0) return false;
10905 28167 itemdata const& itm = itemsbuf[itemid];
10906
5/6
✓ Branch 0 taken 6832 times.
✓ Branch 1 taken 21335 times.
✓ Branch 2 taken 5381 times.
✓ Branch 3 taken 15954 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
28218 if(((dir==up && y<24) || (dir==down && y>128) ||
10907
6/6
✓ Branch 0 taken 7801 times.
✓ Branch 1 taken 8153 times.
✓ Branch 2 taken 8149 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 28112 times.
28167 (dir==left && x<32) || (dir==right && x>208)) && !(get_bit(quest_rules,qr_ITEMSONEDGES) || inlikelike))
10908 51 return false;
10909
10910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28116 times.
28116 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
10911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28116 times.
28116 if(liftonly)
10912 {
10913 dowpn = -1;
10914 switch(itm.family)
10915 {
10916 case itype_bomb:
10917 case itype_sbomb:
10918 if(itm.flags & ITEM_FLAG4)
10919 do_liftglove(-1,false);
10920 break;
10921 case itype_liftglove:
10922 do_liftglove(-1,false);
10923 break;
10924 }
10925 return false;
10926 }
10927
10928 28116 int32_t wx=x;
10929 28116 int32_t wy=y-fakez;
10930 28116 int32_t wz=z;
10931 28116 bool ret = true;
10932
10933
5/5
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6819 times.
✓ Branch 2 taken 5369 times.
✓ Branch 3 taken 7783 times.
✓ Branch 4 taken 8141 times.
28116 switch(dir)
10934 {
10935 case up:
10936 6819 wy-=16;
10937 6819 break;
10938
10939 case down:
10940 5369 wy+=16;
10941 5369 break;
10942
10943 case left:
10944 7783 wx-=16;
10945 7783 break;
10946
10947 case right:
10948 8141 wx+=16;
10949 8141 break;
10950 }
10951
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28116 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
10952
10953
15/27
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
✓ Branch 2 taken 1163 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 92 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 185 times.
✓ Branch 11 taken 718 times.
✓ Branch 12 taken 15 times.
✓ Branch 13 taken 1535 times.
✓ Branch 14 taken 13280 times.
✓ Branch 15 taken 1077 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 823 times.
✓ Branch 18 taken 10 times.
✓ Branch 19 taken 8962 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
28116 switch(itm.family)
10954 {
10955 case itype_liftglove:
10956 {
10957 do_liftglove(itemid,false);
10958 dowpn = -1;
10959 ret = false;
10960 break;
10961 }
10962 case itype_potion:
10963 {
10964
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10965 {
10966 return item_error();
10967 }
10968
10969 23 paymagiccost(itemid);
10970
10971
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23 if(itm.misc1 || itm.misc2)
10972 {
10973 23 refill_what=REFILL_ALL;
10974 23 refill_why=itemid;
10975 23 StartRefill(REFILL_ALL);
10976 23 potion_life = game->get_life();
10977 23 potion_magic = game->get_magic();
10978
10979 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10980 //music_pause();
10981 23 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10982
2/2
✓ Branch 0 taken 4932 times.
✓ Branch 1 taken 23 times.
4955 while(refill())
10983 {
10984 4932 do_refill_waitframe();
10985 }
10986
10987 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10988 //music_resume();
10989 23 ret = false;
10990 23 }
10991
10992 23 break;
10993 }
10994 case itype_bottle:
10995 {
10996 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10997 {
10998 return item_error();
10999 }
11000 if(itm.script!=0 && (item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
11001 return false;
11002
11003 size_t bind = game->get_bottle_slot(itm.misc1);
11004 bool paidmagic = false;
11005 if(itm.script)
11006 {
11007 paidmagic = true;
11008 paymagiccost(itemid);
11009
11010 ri = &(itemScriptData[itemid]);
11011 for ( int32_t q = 0; q < 1024; q++ )
11012 item_stack[itemid][q] = 0xFFFF;
11013 ri->Clear();
11014 item_doscript[itemid] = 1;
11015 itemscriptInitialised[itemid] = 0;
11016 ZScriptVersion::RunScript(SCRIPT_ITEM, itm.script, itemid);
11017 bind = game->get_bottle_slot(itm.misc1);
11018 }
11019 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
11020 if(bt)
11021 {
11022 word toFill[3] = { 0 };
11023 for(size_t q = 0; q < 3; ++q)
11024 {
11025 char c = bt->counter[q];
11026 if(c > -1)
11027 {
11028 if(bt->flags & (1<<q))
11029 {
11030 toFill[q] = (bt->amount[q]==100)
11031 ? game->get_maxcounter(c)
11032 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
11033 }
11034 else toFill[q] = bt->amount[q];
11035 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
11036 {
11037 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
11038 }
11039 }
11040 }
11041 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
11042 bool run = max > 0;
11043 if(get_bit(quest_rules, qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
11044 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
11045 else
11046 {
11047 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
11048 run = true;
11049 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
11050 run = true;
11051 }
11052 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
11053 {
11054 if(bt->flags & BTFLAG_CURESWJINX)
11055 {
11056 swordclk = 0;
11057 verifyAWpn();
11058 }
11059 if(bt->flags & BTFLAG_CUREITJINX)
11060 itemclk = 0;
11061 if(!paidmagic)
11062 paymagiccost(itemid);
11063 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11064 sfx(itm.usesound,pan(x.getInt()));
11065 for(size_t q = 0; q < 20; ++q)
11066 do_refill_waitframe();
11067 double inc = max/60.0; //1 second
11068 double xtra[3]{ 0 };
11069 for(size_t q = 0; q < 60; ++q)
11070 {
11071 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
11072 sfx(QMisc.miscsfx[sfxREFILL]);
11073 for(size_t j = 0; j < 3; ++j)
11074 {
11075 xtra[j] += inc;
11076 word f = floor(xtra[j]);
11077 xtra[j] -= f;
11078 if(toFill[j] > f)
11079 {
11080 toFill[j] -= f;
11081 game->change_counter(f,bt->counter[j]);
11082 }
11083 else if(toFill[j])
11084 {
11085 game->change_counter(toFill[j],bt->counter[j]);
11086 toFill[j] = 0;
11087 }
11088 }
11089 do_refill_waitframe();
11090 }
11091 for(size_t j = 0; j < 3; ++j)
11092 {
11093 if(toFill[j])
11094 {
11095 game->change_counter(toFill[j],bt->counter[j]);
11096 toFill[j] = 0;
11097 }
11098 }
11099 for(size_t q = 0; q < 20; ++q)
11100 do_refill_waitframe();
11101 game->set_bottle_slot(itm.misc1, bt->next_type);
11102 }
11103 }
11104
11105 dowpn = -1;
11106 ret = false;
11107 break;
11108 }
11109
11110 case itype_note:
11111 {
11112 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11113 {
11114 return item_error();
11115 }
11116 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
11117 {
11118 sfx(itm.usesound);
11119 donewmsg(itm.misc1);
11120 paymagiccost(itemid);
11121 }
11122 dowpn = -1;
11123 ret = false;
11124 break;
11125 }
11126
11127 case itype_mirror:
11128 doMirror(itemid);
11129 if(Quit)
11130 return false;
11131 ret = false;
11132 break;
11133
11134 case itype_rocs:
11135 {
11136
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 13 times.
92 if(!do_jump(itemid,false)) return false;
11137 79 ret = false;
11138 }
11139 79 break;
11140
11141 case itype_letter:
11142 {
11143
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 if(current_item(itype_letter)==i_letter &&
11144
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11145
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].guy &&
11146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11147
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11148 4 checkbunny(itemid)
11149 )
11150 {
11151 4 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11152
11153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(usedid != -1)
11154 4 getitem(usedid, true, true);
11155
11156 4 sfx(tmpscr[currscr<128?0:1].secretsfx);
11157 4 setupscreen();
11158 4 action=none; FFCore.setHeroAction(none);
11159 4 }
11160
11161 4 ret = false;
11162 }
11163 4 break;
11164
11165 case itype_whistle:
11166 {
11167 bool whistleflag;
11168
11169
4/4
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 177 times.
185 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11170 {
11171 8 return item_error();
11172 }
11173
11174 177 paymagiccost(itemid);
11175 177 sfx(itm.usesound);
11176
11177
4/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 78 times.
177 if(dir==up || dir==right)
11178 99 ++blowcnt;
11179 else
11180 78 --blowcnt;
11181
11182 177 int sfx_count = 0;
11183
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32757 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32761 times.
✓ Branch 6 taken 32580 times.
✓ Branch 7 taken 185 times.
32757 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < 180))
11184 {
11185 32580 sfx_count += 1;
11186 32580 advanceframe(true);
11187
11188
1/2
✓ Branch 0 taken 32580 times.
✗ Branch 1 not taken.
32580 if(Quit)
11189 return false;
11190 }
11191
11192
9/14
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 181 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 181 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 181 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 181 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 185 times.
✓ Branch 13 taken 4 times.
185 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11193
11194
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 17 times.
185 if((whistleflag=findentrance(x,y,mfWHISTLE,get_bit(quest_rules, qr_PERMANENT_WHISTLE_SECRETS))))
11195 17 didstuff |= did_whistle;
11196
11197
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 166 times.
185 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
11198 19 return false;
11199
11200
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 162 times.
166 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
11201
11202
4/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 136 times.
166 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11203
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 || (tmpscr->flags7&fWHISTLEPAL))
11204 {
11205 30 whistleclk=0; // signal to start drying lake or doing other stuff
11206 30 }
11207 else
11208 {
11209 136 int32_t where = itm.misc1;
11210
11211
1/2
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
136 if(where>right) where=dir^1;
11212
11213
5/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 43 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 89 times.
225 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
11214
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
93 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11215
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 89 times.
✗ Branch 11 not taken.
178 Lwpns.add(new weapon((zfix)(where==left?zfix(240):where==right?zfix(0):x),
11216
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 89 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 89 times.
✗ Branch 9 not taken.
89 (zfix)(where==down?zfix(0):where==up?zfix(160):y),
11217
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 (zfix)0,
11218 wWind,
11219 0, //type
11220 0,
11221 89 where,
11222
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11223
11224 132 whistleitem=itemid;
11225 }
11226
11227 162 ret = false;
11228 }
11229 162 break;
11230
11231 case itype_bomb:
11232 {
11233 //Remote detonation
11234
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 713 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 717 times.
718 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
11235 {
11236 1 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11237
11238
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
11239 {
11240 //If this ever needs a version check, in the future. -z
11241 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
11242 {
11243 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11244 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11245 }
11246 ew->misc=50;
11247 ew->clk=ew->misc-3;
11248 ew->id=wBomb;
11249 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11250 }
11251
11252 1 deselectbombs(false);
11253 1 return false;
11254 }
11255
11256
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
717 if((itm.flags & ITEM_FLAG4) && lift_wpn)
11257 {
11258 do_liftglove(-1,false); //Throw the already-held weapon
11259 return false;
11260 }
11261
2/4
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 717 times.
717 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11262 {
11263 return item_error();
11264 }
11265
11266 717 paymagiccost(itemid);
11267
11268
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(itm.misc1>0) // If not remote bombs
11269 717 deselectbombs(false);
11270
11271
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 578 times.
717 if(isdungeon())
11272 {
11273
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 63 times.
578 wy=zc_max(wy,16);
11274 578 }
11275
11276
4/8
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 717 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 717 times.
✗ Branch 7 not taken.
1434 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
11277
2/4
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 717 times.
✗ Branch 3 not taken.
717 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true);
11278 717 bool lifted = false;
11279
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(itm.flags & ITEM_FLAG4)
11280 {
11281 auto liftid = current_item_id(itype_liftglove);
11282 itemdata const& glove = itemsbuf[liftid];
11283 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
11284 {
11285 lift(wpn,itm.misc5,itm.misc6);
11286 set_liftflags(liftid);
11287 lifted = true;
11288 }
11289 }
11290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
717 if(!lifted)
11291 {
11292 717 Lwpns.add(wpn);
11293 717 sfx(WAV_PLACE,pan(wx));
11294 717 }
11295 }
11296 717 break;
11297
11298 case itype_sbomb:
11299 {
11300 //Remote detonation
11301
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
11302 {
11303 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11304
11305 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
11306 {
11307 ew->misc=50;
11308 ew->clk=ew->misc-3;
11309 ew->id=wSBomb;
11310 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11311 }
11312
11313 deselectbombs(true);
11314 return false;
11315 }
11316
11317
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 if((itm.flags & ITEM_FLAG4) && lift_wpn)
11318 {
11319 do_liftglove(-1,false); //Throw the already-held weapon
11320 return false;
11321 }
11322
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11323 {
11324 return item_error();
11325 }
11326
11327 15 paymagiccost(itemid);
11328
11329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itm.misc1>0) // If not remote bombs
11330 15 deselectbombs(true);
11331
11332
6/12
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
15 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true);
11333 15 bool lifted = false;
11334
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(itm.flags & ITEM_FLAG4)
11335 {
11336 auto liftid = current_item_id(itype_liftglove);
11337 itemdata const& glove = itemsbuf[liftid];
11338 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
11339 {
11340 lift(wpn,itm.misc5,itm.misc6);
11341 set_liftflags(liftid);
11342 lifted = true;
11343 }
11344 }
11345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(!lifted)
11346 {
11347 15 Lwpns.add(wpn);
11348 15 sfx(WAV_PLACE,pan(wx));
11349 15 }
11350 }
11351 15 break;
11352
11353 case itype_wand:
11354 {
11355
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 1096 times.
1535 if(Lwpns.idCount(wMagic))
11356 {
11357 439 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11358 439 return false;
11359 }
11360
11361 1096 int32_t bookid = current_item_id(itype_book);
11362
3/4
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 653 times.
1096 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11363
11364
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1096 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
11365 {
11366 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11367 return false;
11368 }
11369
11370
4/6
✓ Branch 0 taken 1096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1096 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1095 times.
✓ Branch 5 taken 1 times.
1096 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11371 {
11372 1 return item_error();
11373 }
11374
11375
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 3 times.
1095 if(Lwpns.idCount(wBeam))
11376 3 Lwpns.del(Lwpns.idFirst(wBeam));
11377
11378 int32_t type, pow;
11379
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 666 times.
1095 if ( get_bit(quest_rules,qr_BROKENBOOKCOST) )
11380 {
11381
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 79 times.
429 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11382
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 79 times.
429 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11383 429 }
11384 else
11385 {
11386
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
666 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11387
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
666 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11388 }
11389
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2190 times.
✓ Branch 4 taken 1095 times.
✓ Branch 5 taken 1095 times.
2190 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
2190 if(dir!=(i^1))
11391 {
11392
5/10
✓ Branch 0 taken 1095 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1095 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1095 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1095 times.
✗ Branch 9 not taken.
1095 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11393
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 653 times.
1095 if(paybook)
11394 653 magic->linkedItem = bookid;
11395 //magic->dir = this->dir; //Save player dir for special weapons.
11396 1095 Lwpns.add(magic);
11397 1095 }
11398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
1095 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11399 1095 paymagiccost(itemid);
11400 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11401
11402
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 653 times.
1095 if(paybook)
11403 653 paymagiccost(current_item_id(itype_book));
11404
11405
2/2
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 442 times.
1095 if(bookid != -1)
11406 {
11407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 653 times.
653 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
11408 {
11409 sfx(itemsbuf[bookid].misc2,pan(wx));
11410 }
11411 else
11412 {
11413 653 sfx(itm.usesound,pan(wx));
11414 }
11415 653 }
11416 else
11417 442 sfx(itm.usesound,pan(wx));
11418 }
11419 /*
11420 // Fireball Wand
11421 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
11422 switch (dir)
11423 {
11424 case up:
11425 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
11426 Lwpns.spr(Lwpns.Count()-1)->dir=up;
11427 break;
11428 case down:
11429 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
11430 Lwpns.spr(Lwpns.Count()-1)->dir=down;
11431 break;
11432 case left:
11433 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
11434 Lwpns.spr(Lwpns.Count()-1)->dir=left;
11435 break;
11436 case right:
11437 Lwpns.spr(Lwpns.Count()-1)->angle=0;
11438 Lwpns.spr(Lwpns.Count()-1)->dir=right;
11439 break;
11440 }
11441 Lwpns.spr(Lwpns.Count()-1)->clk=16;
11442 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
11443 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
11444 */
11445 1095 break;
11446
11447 case itype_sword:
11448 {
11449
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13280 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13280 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
11450 {
11451 return item_error();
11452 }
11453
11454
4/4
✓ Branch 0 taken 2603 times.
✓ Branch 1 taken 10677 times.
✓ Branch 2 taken 2603 times.
✓ Branch 3 taken 10677 times.
13280 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
11455 {
11456 2603 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11457 2603 return false;
11458 }
11459
11460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10677 times.
10677 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
11461 10677 paymagiccost(itemid);
11462 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11463 float temppower;
11464
11465
1/2
✓ Branch 0 taken 10677 times.
✗ Branch 1 not taken.
10677 if(itm.flags & ITEM_FLAG2)
11466 {
11467 10677 temppower=game->get_hero_dmgmult()*itm.power;
11468 10677 temppower=temppower*itm.misc2;
11469 10677 temppower=temppower/100;
11470 10677 }
11471 else
11472 {
11473 temppower = game->get_hero_dmgmult()*itm.misc2;
11474 }
11475
11476 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
11477 //Add weapon script to sword beams.
11478
5/10
✓ Branch 0 taken 10677 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10677 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10677 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10677 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10677 times.
✗ Branch 9 not taken.
10677 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
11479 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
11480 //w->weaponscript = itm.weaponscript;
11481 //w->canrunscript = 0;
11482 10677 sfx(WAV_BEAM,pan(wx));
11483 }
11484 10677 break;
11485
11486 case itype_candle:
11487 {
11488 1077 int32_t countid = itemid;
11489
2/2
✓ Branch 0 taken 1049 times.
✓ Branch 1 taken 28 times.
1077 if(get_bit(quest_rules, qr_CANDLES_SHARED_LIMIT))
11490 1049 countid = -itype_candle;
11491
5/6
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 266 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 1067 times.
1077 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
11492 {
11493 10 return false;
11494 }
11495
11496
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1067 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 1004 times.
1067 if(Lwpns.idCount(wFire) >= (itm.misc2 < 1 ? 2 : itm.misc2))
11497 {
11498 63 return false;
11499 }
11500
11501
3/4
✓ Branch 0 taken 1004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 996 times.
1004 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11502 {
11503 8 return item_error();
11504 }
11505
11506 996 paymagiccost(itemid);
11507
11508
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 248 times.
996 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
11509
11510
4/8
✓ Branch 0 taken 996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 996 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 996 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 996 times.
✗ Branch 7 not taken.
1992 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
11511 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11512 996 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11513
2/4
✓ Branch 0 taken 996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 996 times.
✗ Branch 3 not taken.
996 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11514 996 sfx(itm.usesound,pan(wx));
11515 996 attack=wFire;
11516 }
11517 996 break;
11518
11519 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
11520 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
11521 {
11522 int32_t wtype = wScript1 + (itm.family-itype_script1);
11523 if(Lwpns.idCount(wtype))
11524 return false;
11525
11526 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11527 {
11528 return item_error();
11529 }
11530
11531 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11532 paymagiccost(itemid);
11533
11534 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11535 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11536 sfx(itm.usesound,pan(wx));
11537 }
11538 break;
11539
11540 case itype_icerod:
11541 {
11542 if(Lwpns.idCount(wIce))
11543 return false;
11544
11545 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11546 {
11547 return item_error();
11548 }
11549
11550 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11551 paymagiccost(itemid);
11552
11553 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11554 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11555 sfx(itm.usesound,pan(wx));
11556 }
11557 break;
11558
11559 case itype_arrow:
11560 {
11561
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 823 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 789 times.
823 if(Lwpns.idCount(wArrow) >= (itm.misc2 < 1 ? 1 : itm.misc2))
11562 34 return false;
11563
11564
2/4
✓ Branch 0 taken 789 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 789 times.
789 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11565 {
11566 return item_error();
11567 }
11568
11569 789 paymagiccost(itemid);
11570
11571
6/12
✓ Branch 0 taken 789 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 789 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 789 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 789 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 789 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 789 times.
✗ Branch 11 not taken.
789 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11572 789 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
11573 789 sfx(itm.usesound,pan(wx));
11574 }
11575 789 break;
11576
11577 case itype_bait:
11578 {
11579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
11580 return false;
11581
11582
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if(!checkbunny(itemid))
11583 3 return item_error();
11584
11585
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 bool grumble = (tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)));
11586
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 bool checkcost = grumble || !(itm.flags & ITEM_FLAG4);
11587
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 bool paycost = grumble || !(itm.flags & (ITEM_FLAG4|ITEM_FLAG5));
11588
11589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 if(!grumble && (itm.flags & ITEM_FLAG2))
11590 return item_error(); //Only usable for grumble rooms
11591
11592
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 if(checkcost && !checkmagiccost(itemid))
11593 return item_error();
11594
11595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(paycost)
11596 7 paymagiccost(itemid);
11597 7 sfx(itm.usesound,pan(wx));
11598
11599
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(grumble)
11600 {
11601
4/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
7 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
11602 7 fadeclk=66;
11603 7 dismissmsg();
11604 7 clear_bitmap(pricesdisplaybuf);
11605 7 set_clip_state(pricesdisplaybuf, 1);
11606 // putscr(scrollbuf,0,0,tmpscr);
11607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
11608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(!(itm.flags & ITEM_FLAG3)) //"Don't remove when feeding" flag
11609 {
11610 7 removeItemsOfFamily(game,itemsbuf,itype_bait);
11611 7 verifyBothWeapons();
11612 7 }
11613 7 sfx(tmpscr->secretsfx);
11614 7 return false;
11615 }
11616
11617 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
11618 break;
11619 }
11620
11621 case itype_brang:
11622 {
11623
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 8673 times.
8962 if(Lwpns.idCount(wBrang) > itm.misc2)
11624 289 return false;
11625
11626
2/4
✓ Branch 0 taken 8673 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8673 times.
8673 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11627 {
11628 return item_error();
11629 }
11630
11631 8673 paymagiccost(itemid);
11632 8673 current_item_power(itype_brang);
11633
6/12
✓ Branch 0 taken 8673 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8673 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8673 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8673 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8673 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8673 times.
✗ Branch 11 not taken.
8673 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
11634 }
11635 8673 break;
11636
11637 case itype_hookshot:
11638 case itype_switchhook:
11639 {
11640
2/4
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225 times.
225 if(inlikelike || Lwpns.idCount(wHookshot))
11641 return false;
11642
11643
2/4
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225 times.
225 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11644 {
11645 return item_error();
11646 }
11647 225 bool sw = itm.family == itype_switchhook;
11648
11649
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
225 if(sw && (itm.flags&ITEM_FLAG8))
11650 switchhook_cost_item = itemid;
11651 225 else paymagiccost(itemid);
11652
11653 225 bool use_hookshot=true;
11654 225 bool hit_hs = false, hit_solid = false, insta_switch = false;
11655
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 222 times.
225 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11656 225 int32_t cpos = -1, ffcpos = -1;
11657
4/4
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 243 times.
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 225 times.
468 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
11658 {
11659
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 49 times.
243 if(dir==up)
11660 {
11661
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 1 times.
49 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
11662 1 hit_hs = true;
11663 49 }
11664
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 155 times.
194 else if(dir==down)
11665 {
11666
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
11667 hit_hs = true;
11668 39 }
11669
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 89 times.
155 else if(dir==left)
11670 {
11671
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
11672 hit_hs = true;
11673 66 }
11674
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 else if(dir==right)
11675 {
11676
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
11677 hit_hs = true;
11678 89 }
11679 //Diagonal Hookshot (6)
11680 else if(dir==r_down)
11681 {
11682 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11683 hit_hs = true;
11684 }
11685 else if(dir==l_down)
11686 {
11687 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11688 hit_hs = true;
11689 }
11690 else if(dir==r_up)
11691 {
11692 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11693 hit_hs = true;
11694 }
11695 else if(dir==l_up)
11696 {
11697 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11698 hit_hs = true;
11699 }
11700 243 }
11701
8/10
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 44 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 223 times.
✓ Branch 9 taken 2 times.
225 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
11702 2 hit_solid = true;
11703
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1 times.
225 if(hit_hs)
11704 {
11705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(sw)
11706 insta_switch = true; //switch immediately
11707 1 else use_hookshot = false; //No hooking against grabbable
11708 1 }
11709
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 223 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
225 if(hit_solid && !insta_switch)
11710 2 use_hookshot = false;
11711
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 222 times.
225 if(use_hookshot)
11712 {
11713 222 int32_t hookitem = itm.fam_type;
11714 222 int32_t hookpower = itm.power;
11715 222 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
11716
11717
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!Lwpns.has_space())
11718 {
11719 Lwpns.del(0);
11720 }
11721
11722
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!Lwpns.has_space(2))
11723 {
11724 Lwpns.del(0);
11725 }
11726
11727
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
222 switch(dir)
11728 {
11729 case up:
11730 {
11731 46 hookshot_used=true;
11732 46 hs_switcher = sw;
11733
4/8
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✗ Branch 7 not taken.
92 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11734
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
46 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11735 46 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11736
5/10
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 46 times.
✗ Branch 9 not taken.
92 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
11737
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
46 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11738 46 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11739 46 hs_startx=wx;
11740 46 hs_starty=wy-4;
11741 }
11742 46 break;
11743
11744 case down:
11745 {
11746 39 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11747 39 hookshot_used=true;
11748 39 hs_switcher = sw;
11749
5/10
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
78 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11750
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11751 39 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11752
5/10
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
78 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11753
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11754 39 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11755 39 hs_startx=wx;
11756 39 hs_starty=wy;
11757 }
11758 39 break;
11759
11760 case left:
11761 {
11762 54 hookshot_used=true;
11763 54 hs_switcher = sw;
11764
4/8
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
108 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11765
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11766 54 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11767
4/8
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
108 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11768
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11769 54 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11770 54 hs_startx=wx-4;
11771 54 hs_starty=wy;
11772 }
11773 54 break;
11774
11775 case right:
11776 {
11777 83 hookshot_used=true;
11778 83 hs_switcher = sw;
11779
4/8
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 83 times.
✗ Branch 7 not taken.
166 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11780
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11781 83 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11782
4/8
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 83 times.
✗ Branch 7 not taken.
166 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11783
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11784 83 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11785 83 hs_startx=wx+4;
11786 83 hs_starty=wy;
11787 }
11788 83 break;
11789 //Diagonal Hookshot (7)
11790 case r_down:
11791 {
11792 hookshot_used=true;
11793 hs_switcher = sw;
11794 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11795 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11796 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11797 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11798 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11799 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11800 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11801 hs_startx=wx+4;
11802 hs_starty=wy;
11803 }
11804 break;
11805
11806 case r_up:
11807 {
11808 hookshot_used=true;
11809 hs_switcher = sw;
11810 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11811 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11812 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11813 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11814 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11815 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11816 hs_startx=wx+4;
11817 hs_starty=wy;
11818 }
11819 break;
11820
11821 case l_down:
11822 {
11823 hookshot_used=true;
11824 hs_switcher = sw;
11825 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11826 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11827 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11828 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11829 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11830 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11831 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11832 hs_startx=wx+4;
11833 hs_starty=wy;
11834 }
11835 break;
11836
11837 case l_up:
11838 {
11839 hookshot_used=true;
11840 hs_switcher = sw;
11841 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11842 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11843 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11844 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11845 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11846 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11847 hs_startx=wx+4;
11848 hs_starty=wy;
11849 }
11850 break;
11851 }
11852 222 hookshot_frozen=true;
11853 222 }
11854
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(insta_switch)
11855 {
11856 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
11857 if (cpos > -1) hooked_combopos = cpos;
11858 if (ffcpos > -1)
11859 {
11860 switching_object = &(tmpscr->ffcs[ffcpos]);
11861 switching_object->switch_hooked = true;
11862 }
11863 w->misc=2;
11864 w->step=0;
11865 doSwitchHook(itm.misc5);
11866 if(itm.usesound2)
11867 sfx(itm.usesound2,pan(int32_t(x)));
11868 else if(QMisc.miscsfx[sfxSWITCHED])
11869 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
11870 stop_sfx(itm.usesound);
11871 }
11872 }
11873 225 break;
11874
11875 case itype_divinefire:
11876 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11877 return false;
11878
11879 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11880 {
11881 return item_error();
11882 }
11883
11884 paymagiccost(itemid);
11885 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11886 else {action=casting; FFCore.setHeroAction(casting);}
11887 magicitem=itemid;
11888 break;
11889
11890 case itype_divineescape:
11891 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11892 return false;
11893
11894 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11895 {
11896 return item_error();
11897 }
11898
11899 paymagiccost(itemid);
11900 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11901 else {action=casting; FFCore.setHeroAction(casting);}
11902 magicitem=itemid;
11903 break;
11904
11905 case itype_divineprotection:
11906 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11907 return false;
11908
11909 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11910 {
11911 return item_error();
11912 }
11913
11914 paymagiccost(itemid);
11915 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11916 else {action=casting; FFCore.setHeroAction(casting);}
11917 magicitem=itemid;
11918 break;
11919
11920 case itype_cbyrna:
11921 {
11922 //Beams already deployed
11923
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(Lwpns.idCount(wCByrna))
11924 {
11925 2 stopCaneOfByrna();
11926 2 return false;
11927 }
11928
11929
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11930 {
11931 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
11932 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
11933 return false;
11934 }
11935
11936 2 paymagiccost(itemid);
11937 2 last_cane_of_byrna_item_id = itemid;
11938 //zprint("itm.misc3: %d\n", itm.misc3);
11939
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for(int32_t i=0; i<itm.misc3; i++)
11940 {
11941 //byrna weapons are added here
11942 //space them apart
11943 //zprint("Added byrna weapon %d.\n", i);
11944 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
11945 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
11946
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11947 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11948 //wx += cos(2 * PI / (itm.misc3-i));
11949 //wy += sin(2 * PI / (itm.misc3-i));
11950 2 }
11951
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(Lwpns.idCount(wCByrna)))
11952 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
11953 }
11954 2 break;
11955
11956 case itype_clock:
11957 {
11958 ret = false;
11959 if(!(itm.flags & ITEM_FLAG1))
11960 break; //Passive clock, don't use
11961 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
11962 break;
11963 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
11964 {
11965 return item_error();
11966 }
11967
11968 paymagiccost(itemid);
11969
11970 setClock(watch=true);
11971
11972 for(int32_t i=0; i<eMAXGUYS; i++)
11973 clock_zoras[i]=0;
11974
11975 clockclk=itm.misc1;
11976 sfx(itm.usesound);
11977 break;
11978 }
11979 case itype_killem:
11980 {
11981 ret = false;
11982 if(!(itm.flags & ITEM_FLAG1))
11983 break; //Passive killemall, don't use
11984
11985 if(!(checkbunny(itemid) && checkmagiccost(itemid))
11986 || !can_kill_em_all()) //No enemies onscreen
11987 {
11988 return item_error();
11989 }
11990
11991 paymagiccost(itemid);
11992
11993 kill_em_all();
11994 sfx(itm.usesound);
11995 break;
11996 }
11997 case itype_refill:
11998 {
11999 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12000 {
12001 return item_error();
12002 }
12003
12004 bool did_something = false;
12005
12006 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
12007 {
12008 if(swordclk)
12009 did_something = true;
12010 swordclk = 0;
12011 verifyAWpn();
12012 }
12013 for(auto q = 0; q < 5; ++q)
12014 {
12015 auto ctr = itm.misc(q);
12016 if(unsigned(ctr) >= MAX_COUNTERS)
12017 continue;
12018 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
12019 if(!amnt) continue;
12020 bool gradual = itm.flags & ITEM_FLAG2;
12021 if(amnt > 0)
12022 {
12023 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
12024 {
12025 //Can't *do* anything... skip
12026 continue;
12027 }
12028 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
12029 {
12030 //Can't do anything unless affecting dcounter
12031 gradual = true;
12032 }
12033 }
12034 else //Negative
12035 {
12036 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
12037 {
12038 //Can't *do* anything... skip
12039 continue;
12040 }
12041 if(game->get_counter(ctr) <= 0)
12042 {
12043 //Can't do anything unless affecting dcounter
12044 gradual = true;
12045 }
12046 }
12047 did_something = true;
12048 if(gradual) //Gradual
12049 {
12050 game->change_dcounter(amnt, ctr);
12051 }
12052 else
12053 {
12054 game->change_counter(amnt, ctr);
12055 }
12056 }
12057 if(!did_something)
12058 {
12059 return item_error();
12060 }
12061 paymagiccost(itemid);
12062 sfx(itm.usesound);
12063 ret = false;
12064 break;
12065 }
12066
12067 default:
12068 1163 ret = false;
12069 1163 }
12070
12071
2/2
✓ Branch 0 taken 24597 times.
✓ Branch 1 taken 23 times.
24620 if(itm.flags & ITEM_DOWNGRADE)
12072 {
12073 23 game->set_item(itemid,false);
12074
12075 // Maybe Item Override has allowed the same item in both slots?
12076
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Bwpn == itemid)
12077 {
12078 Bwpn = 0;
12079 game->forced_bwpn = -1;
12080 verifyBWpn();
12081 }
12082
12083
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Awpn == itemid)
12084 {
12085 Awpn = 0;
12086 game->forced_awpn = -1;
12087 verifyAWpn();
12088 }
12089
12090
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Xwpn == itemid)
12091 {
12092 Xwpn = 0;
12093 game->forced_xwpn = -1;
12094 verifyXWpn();
12095 }
12096
12097
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Ywpn == itemid)
12098 {
12099 Ywpn = 0;
12100 game->forced_ywpn = -1;
12101 verifyYWpn();
12102 }
12103 23 }
12104
12105 24620 return ret;
12106 28436 }
12107
12108
12109 886123 bool HeroClass::doattack()
12110 {
12111
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 886123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
886123 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
12112 return false;
12113 //int32_t s = BSZ ? 0 : 11;
12114 886123 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
12115
12116
3/4
✓ Branch 0 taken 31486 times.
✓ Branch 1 taken 854637 times.
✓ Branch 2 taken 31486 times.
✗ Branch 3 not taken.
886123 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
12117
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 886123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
886123 if(attack==wBugNet && bugnetid!=-1)
12118 {
12119 if(++attackclk >= NET_CLK_TOTAL)
12120 return false;
12121
12122 return true;
12123 }
12124
12125 // Abort attack if attackclk has run out and:
12126 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
12127 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
12128
12129
6/6
✓ Branch 0 taken 60795 times.
✓ Branch 1 taken 825328 times.
✓ Branch 2 taken 48526 times.
✓ Branch 3 taken 12269 times.
✓ Branch 4 taken 2287 times.
✓ Branch 5 taken 3601 times.
892011 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12130
12/12
✓ Branch 0 taken 40621 times.
✓ Branch 1 taken 7905 times.
✓ Branch 2 taken 3586 times.
✓ Branch 3 taken 37035 times.
✓ Branch 4 taken 43407 times.
✓ Branch 5 taken 5119 times.
✓ Branch 6 taken 42638 times.
✓ Branch 7 taken 769 times.
✓ Branch 8 taken 3585 times.
✓ Branch 9 taken 2303 times.
✓ Branch 10 taken 2264 times.
✓ Branch 11 taken 1321 times.
48526 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12131 {
12132 46239 tapping=false;
12133 46239 return false;
12134 }
12135
12136
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 839163 times.
839884 if(attackclk>29)
12137 {
12138 721 tapping=false;
12139 721 return false;
12140 }
12141
12142
4/4
✓ Branch 0 taken 29499 times.
✓ Branch 1 taken 809664 times.
✓ Branch 2 taken 27699 times.
✓ Branch 3 taken 1800 times.
839163 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
12143
3/4
✓ Branch 0 taken 29499 times.
✓ Branch 1 taken 809664 times.
✓ Branch 2 taken 29499 times.
✗ Branch 3 not taken.
839163 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12144 // An attack can be "walked out-of" after 8 frames, unless it's:
12145 // * a sword stab
12146 // * a hammer pound
12147 // * a wand thrust
12148 // * a candle thrust
12149 // * a cane thrust
12150 // In which case it should continue.
12151
8/8
✓ Branch 0 taken 43731 times.
✓ Branch 1 taken 795432 times.
✓ Branch 2 taken 105688 times.
✓ Branch 3 taken 61957 times.
✓ Branch 4 taken 741442 times.
✓ Branch 5 taken 115947 times.
✓ Branch 6 taken 185575 times.
✓ Branch 7 taken 555867 times.
1002629 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12152
5/6
✓ Branch 0 taken 163496 times.
✓ Branch 1 taken 22079 times.
✓ Branch 2 taken 13177 times.
✓ Branch 3 taken 150319 times.
✓ Branch 4 taken 13177 times.
✗ Branch 5 not taken.
185575 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12153
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 150289 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
163496 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12154
2/2
✓ Branch 0 taken 163466 times.
✓ Branch 1 taken 13177 times.
150319 && (attack != wBugNet) && attackclk>7))
12155 {
12156
8/8
✓ Branch 0 taken 54946 times.
✓ Branch 1 taken 2832 times.
✓ Branch 2 taken 52594 times.
✓ Branch 3 taken 2352 times.
✓ Branch 4 taken 49849 times.
✓ Branch 5 taken 2745 times.
✓ Branch 6 taken 2921 times.
✓ Branch 7 taken 46928 times.
269154 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
12157 {
12158 10850 lstep = s;
12159 10850 return false;
12160 }
12161 46928 }
12162
12163
2/2
✓ Branch 0 taken 1916 times.
✓ Branch 1 taken 765289 times.
767205 if(charging==0)
12164 {
12165 765289 lstep=0;
12166 765289 }
12167
12168 // Work out the sword charge-up delay
12169 767205 int32_t magiccharge = 192, normalcharge = 64;
12170 767205 int32_t itemid = current_item_id(itype_chargering);
12171
12172
2/2
✓ Branch 0 taken 728138 times.
✓ Branch 1 taken 39067 times.
767205 if(itemid>=0)
12173 {
12174 39067 normalcharge = itemsbuf[itemid].misc1;
12175 39067 magiccharge = itemsbuf[itemid].misc2;
12176 39067 }
12177
12178 767205 int scrollid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12179 767205 int scroll2id = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12180
12181 767205 bool doCharge=true;
12182
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 767205 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
767205 if(z!=0 && fakez != 0)
12183 doCharge=false;
12184
2/2
✓ Branch 0 taken 555867 times.
✓ Branch 1 taken 211338 times.
767205 if(attack==wSword)
12185 {
12186
4/4
✓ Branch 0 taken 1661 times.
✓ Branch 1 taken 554206 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1637 times.
555867 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12187 554230 doCharge=false;
12188
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 1220 times.
1637 else if(charging<=normalcharge)
12189 {
12190
3/6
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1220 times.
✗ Branch 5 not taken.
1220 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12191 doCharge=false;
12192 1220 }
12193 555867 }
12194
2/2
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 189259 times.
211338 else if(attack==wHammer)
12195 {
12196
4/4
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 21330 times.
✓ Branch 2 taken 740 times.
✓ Branch 3 taken 9 times.
22079 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12197 22070 doCharge=false;
12198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(charging<=normalcharge)
12199 {
12200
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
9 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12201 1 doCharge=false;
12202 9 }
12203 22079 }
12204 else
12205 189259 doCharge=false;
12206
12207 // charging up weapon...
12208
2/2
✓ Branch 0 taken 1645 times.
✓ Branch 1 taken 765560 times.
767205 if(doCharge)
12209 {
12210 // Increase charging while holding down button.
12211
3/4
✓ Branch 0 taken 1645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1517 times.
1645 if(spins==0 && charging<magiccharge)
12212 1517 charging++;
12213
12214 // Once a charging threshold is reached, play the sound.
12215
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1636 times.
1645 if(charging==normalcharge)
12216 {
12217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!(itemsbuf[scrollid].flags&ITEM_FLAG1))
12218 9 paymagiccost(scrollid);
12219 9 sfx(itemsbuf[scrollid].usesound2,pan(x.getInt()));
12220 9 }
12221
2/2
✓ Branch 0 taken 1633 times.
✓ Branch 1 taken 3 times.
1636 else if(charging==magiccharge)
12222 {
12223
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(scroll2id>-1 && checkbunny(scroll2id) && checkmagiccost(scroll2id))
12224 {
12225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(itemsbuf[scroll2id].flags&ITEM_FLAG1))
12226 3 paymagiccost(scroll2id);
12227 3 charging++; // charging>magiccharge signifies a successful supercharge.
12228 3 sfx(itemsbuf[scroll2id].usesound2,pan(x.getInt()));
12229 3 }
12230 3 }
12231 1645 }
12232
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 765530 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
765560 else if(attack==wCByrna && byrnaid!=-1)
12233 {
12234
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!(itemsbuf[byrnaid].wpn))
12235 {
12236 attack = wNone;
12237 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12238 }
12239
12240 30 bool beamcount = false;
12241
12242
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 55 times.
81 for(int32_t i=0; i<Lwpns.Count(); i++)
12243 {
12244 55 weapon *w = ((weapon*)Lwpns.spr(i));
12245
12246
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 4 times.
55 if(w->id==wCByrna)
12247 {
12248 4 beamcount = true;
12249 4 break;
12250 }
12251 51 }
12252
12253 // If beams already deployed, remove them
12254
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
30 if(!attackclk && beamcount)
12255 {
12256 2 return startwpn(attackid); // Remove beams instantly
12257 }
12258
12259 // Otherwise, continue
12260 28 ++attackclk;
12261 28 }
12262 else
12263 {
12264 765530 ++attackclk;
12265
12266
6/6
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 764732 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 773 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 14 times.
765530 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12267 {
12268 14 ++attackclk; // Won't continue charging
12269 14 charging=0;
12270 14 }
12271
12272 // Faster if spinning.
12273
2/2
✓ Branch 0 taken 764938 times.
✓ Branch 1 taken 592 times.
765530 if(spins>0)
12274 592 ++attackclk;
12275
12276 // Even faster if hurricane spinning.
12277
2/2
✓ Branch 0 taken 765098 times.
✓ Branch 1 taken 432 times.
765530 if(spins>5)
12278 432 attackclk+=2;
12279
12280 // If at a charging threshold, do a charged attack.
12281
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 765416 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✓ Branch 5 taken 8 times.
765530 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12282 {
12283
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(attack==wSword)
12284 {
12285
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 bool super = charging>magiccharge && scroll2id > -1;
12286
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 int id = super ? scroll2id : scrollid;
12287 8 itemdata const& spinscroll = itemsbuf[id];
12288 8 bool paid = !(spinscroll.flags&ITEM_FLAG1);
12289
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8 if(!paid && checkbunny(id) && checkmagiccost(id))
12290 {
12291 paid = true;
12292 paymagiccost(id);
12293 }
12294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(paid)
12295 {
12296 8 currentscroll = id;
12297 8 spins=(spinscroll.misc1*4) + (super ? -3 : 1);
12298 8 attackclk=1;
12299 8 sfx(spinscroll.usesound,pan(x.getInt()));
12300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(spinscroll.flags&ITEM_FLAG1)
12301 paymagiccost(id);
12302 8 }
12303 8 }
12304 else if(attack==wHammer && sideviewhammerpound())
12305 {
12306 bool super = charging>magiccharge && scroll2id > -1;
12307 int id = super ? scroll2id : scrollid;
12308 itemdata const& quakescroll = itemsbuf[id];
12309 bool paid = !(quakescroll.flags&ITEM_FLAG1);
12310 if(!paid && checkbunny(id) && checkmagiccost(id))
12311 {
12312 paid = true;
12313 paymagiccost(id);
12314 }
12315 if(paid)
12316 {
12317 currentscroll = id;
12318 spins = super ? 2 : 1;
12319 sfx(quakescroll.usesound,pan(x.getInt()));
12320 quakeclk=quakescroll.misc1;
12321
12322 // general area stun
12323 for(int32_t i=0; i<GuyCount(); i++)
12324 {
12325 if(!isflier(GuyID(i)))
12326 {
12327 StunGuy(i,quakescroll.misc2-distance(x,y,GuyX(i),GuyY(i)));
12328 }
12329 }
12330
12331 int hmrid = (directWpn>-1 && itemsbuf[directWpn].family==itype_hammer) ? directWpn : current_item_id(itype_hammer);
12332 int hmrlvl = hmrid < 0 ? 1 : itemsbuf[hmrid].fam_type;
12333 if(hmrlvl < 1) hmrlvl = 1;
12334 int rad = quakescroll.misc2;
12335 for(int pos = 0; pos < 176; ++pos)
12336 {
12337 if(distance(x,y,COMBOX(pos),COMBOY(pos)) > rad) continue;
12338 for(int lyr = 0; lyr < 7; ++lyr)
12339 {
12340 int cid = FFCore.tempScreens[lyr]->data[pos];
12341 newcombo const& cmb = combobuf[cid];
12342 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
12343 {
12344 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
12345 ? hmrlvl <= cmb.triggerlevel
12346 : hmrlvl >= cmb.triggerlevel)
12347 do_trigger_combo(lyr,pos);
12348 }
12349 }
12350 }
12351 word c = tmpscr->numFFC();
12352 for(int ff = 0; ff < c; ++ff)
12353 {
12354 ffcdata& ffc = tmpscr->ffcs[ff];
12355 newcombo const& cmb = combobuf[ffc.getData()];
12356 if(distance(x,y,ffc.x,ffc.y) > rad) continue;
12357 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
12358 {
12359 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
12360 ? hmrlvl <= cmb.triggerlevel
12361 : hmrlvl >= cmb.triggerlevel)
12362 do_trigger_combo_ffc(ff);
12363 }
12364 }
12365 }
12366 }
12367 8 }
12368
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 765407 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 48 times.
765522 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12369 48 charging++;
12370
12371
7/8
✓ Branch 0 taken 12950 times.
✓ Branch 1 taken 752580 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 752580 times.
✓ Branch 4 taken 21500 times.
✓ Branch 5 taken 731080 times.
✓ Branch 6 taken 450801 times.
✓ Branch 7 taken 314729 times.
765530 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12372 314729 charging=0;
12373
12374
2/2
✓ Branch 0 taken 757431 times.
✓ Branch 1 taken 8099 times.
765530 if(attackclk>=SWORDCHARGEFRAME)
12375 8099 tapping = false;
12376 }
12377
12378
6/8
✓ Branch 0 taken 60482 times.
✓ Branch 1 taken 706721 times.
✓ Branch 2 taken 1087 times.
✓ Branch 3 taken 59395 times.
✓ Branch 4 taken 1087 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1087 times.
767203 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12379 {
12380 1087 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12381 }
12382
12383 766116 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12384
12385
11/14
✓ Branch 0 taken 718702 times.
✓ Branch 1 taken 47414 times.
✓ Branch 2 taken 54820 times.
✓ Branch 3 taken 663882 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 54788 times.
✓ Branch 6 taken 32 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
766116 if(attackclk==13 || (attackclk==7 && spins>1 && attack != wHammer && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12386 {
12387
12388
4/4
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 45423 times.
✓ Branch 2 taken 578 times.
✓ Branch 3 taken 1425 times.
47426 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12389
2/2
✓ Branch 0 taken 47408 times.
✓ Branch 1 taken 18 times.
47426 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12390
12391
4/4
✓ Branch 0 taken 47408 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 3683 times.
✓ Branch 3 taken 43725 times.
47426 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
12392 {
12393 43725 templife=templife*game->get_maxlife();
12394 43725 templife=templife/100;
12395 43725 }
12396 else
12397 {
12398 3701 templife*=game->get_hp_per_heart();
12399 }
12400
12401
2/2
✓ Branch 0 taken 17178 times.
✓ Branch 1 taken 30248 times.
47426 bool normalbeam = (int64_t(game->get_life())+(get_bit(quest_rules,qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12402 47426 int32_t perilid = current_item_id(itype_perilscroll);
12403
3/4
✓ Branch 0 taken 1637 times.
✓ Branch 1 taken 45789 times.
✓ Branch 2 taken 1637 times.
✗ Branch 3 not taken.
47429 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12404
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1634 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
1637 && checkbunny(perilid) && checkmagiccost(perilid)
12405 // Must actually be able to shoot sword beams
12406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
12407
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12408
12409
4/4
✓ Branch 0 taken 38502 times.
✓ Branch 1 taken 8924 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 38483 times.
47426 if(attack==wSword && !tapping)
12410 {
12411
4/4
✓ Branch 0 taken 38480 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 13300 times.
✓ Branch 3 taken 25180 times.
38483 if(perilbeam || normalbeam)
12412 {
12413
1/2
✓ Branch 0 taken 13303 times.
✗ Branch 1 not taken.
13303 if(attackclk==7)
12414 paymagiccost(crossid); // Pay the Cross Beams magic cost.
12415
12416
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
13303 if(perilbeam && !normalbeam)
12417 3 paymagiccost(perilid); // Pay the Peril Beam magic cost.
12418
12419 // TODO: Something that would be cheap but disgraceful to hack in at this point is
12420 // a way to make the peril/cross beam item's power stat influence the strength
12421 // of the peril/cross beam...
12422 13303 startwpn(attackid);
12423 13303 }
12424 25180 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12425 38483 }
12426
12427
2/2
✓ Branch 0 taken 45891 times.
✓ Branch 1 taken 1535 times.
47426 if(attack==wWand)
12428 1535 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
12429
12430
4/6
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 46634 times.
✓ Branch 2 taken 792 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 792 times.
✗ Branch 5 not taken.
47426 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
12431 startwpn(attackid);
12432
12433
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 47424 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
47426 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
12434 2 startwpn(attackid);
12435 47426 }
12436
12437
2/2
✓ Branch 0 taken 719189 times.
✓ Branch 1 taken 46927 times.
766116 if(attackclk==14)
12438 46927 lstep = s;
12439
12440 766116 return true;
12441 825015 }
12442
12443 12257584 bool HeroClass::can_attack()
12444 {
12445
4/4
✓ Branch 0 taken 12048254 times.
✓ Branch 1 taken 209330 times.
✓ Branch 2 taken 7188792 times.
✓ Branch 3 taken 4859462 times.
12257584 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
12446
4/6
✓ Branch 0 taken 12257584 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12129180 times.
✓ Branch 3 taken 128404 times.
✓ Branch 4 taken 12129180 times.
✗ Branch 5 not taken.
13107570 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
12447
5/8
✓ Branch 0 taken 12129180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12129180 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12129180 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12127484 times.
✓ Branch 7 taken 1696 times.
12129180 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
12448
3/4
✓ Branch 0 taken 12127484 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10556092 times.
✓ Branch 3 taken 1571392 times.
12127484 || ((action==attacking||action==sideswimattacking)
12449
2/2
✓ Branch 0 taken 425000 times.
✓ Branch 1 taken 11702484 times.
12127484 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
12450
2/2
✓ Branch 0 taken 12127470 times.
✓ Branch 1 taken 424986 times.
12127484 && charging!=0))
12451 {
12452 980086 return false;
12453 }
12454
12455 12127470 int32_t r = (isdungeon()) ? 16 : 0;
12456 12127470 int32_t r2 = get_bit(quest_rules, qr_NOBORDER) ? 0 : 8;
12457
12458
4/5
✓ Branch 0 taken 3402550 times.
✓ Branch 1 taken 8724920 times.
✓ Branch 2 taken 3846284 times.
✓ Branch 3 taken 4878636 times.
✗ Branch 4 not taken.
12127470 if(!get_bit(quest_rules, qr_ITEMSONEDGES)) switch(dir)
12459 {
12460 case up:
12461 case down:
12462
2/2
✓ Branch 0 taken 3695346 times.
✓ Branch 1 taken 150938 times.
3846284 return !(y<(r2+r) || y>(160-r-r2));
12463
12464 case left:
12465 case right:
12466
2/2
✓ Branch 0 taken 4725154 times.
✓ Branch 1 taken 153482 times.
4878636 return !(x<(r2+r) || x>(240-r-r2));
12467 }
12468
12469 3402550 return true;
12470 13107556 }
12471
12472 8884 bool isRaftFlag(int32_t flag)
12473 {
12474
4/4
✓ Branch 0 taken 4567 times.
✓ Branch 1 taken 4317 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 4345 times.
8884 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
12475 }
12476
12477 3712135 void handle_lens_triggers(int32_t l_id)
12478 {
12479
2/2
✓ Branch 0 taken 3705876 times.
✓ Branch 1 taken 6259 times.
3712135 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
12480
2/2
✓ Branch 0 taken 3712135 times.
✓ Branch 1 taken 25984945 times.
29697080 for(auto layer = 0; layer < 7; ++layer)
12481 {
12482 25984945 mapscr* tmp = FFCore.tempScreens[layer];
12483
2/2
✓ Branch 0 taken 4573350320 times.
✓ Branch 1 taken 25984945 times.
4599335265 for(auto pos = 0; pos < 176; ++pos)
12484 {
12485 4573350320 newcombo const& cmb = combobuf[tmp->data[pos]];
12486
4/4
✓ Branch 0 taken 280896 times.
✓ Branch 1 taken 4573069424 times.
✓ Branch 2 taken 4573350134 times.
✓ Branch 3 taken 186 times.
4573350320 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12487 4573069424 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12488 {
12489 186 do_trigger_combo(layer, pos);
12490 186 }
12491 4573350320 }
12492 25984945 }
12493
2/2
✓ Branch 0 taken 3555575 times.
✓ Branch 1 taken 156560 times.
3712135 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
12494 {
12495 156560 word c = tmpscr->numFFC();
12496
2/2
✓ Branch 0 taken 156560 times.
✓ Branch 1 taken 916595 times.
1073155 for(word i=0; i<c; i++)
12497 {
12498 916595 ffcdata& ffc = tmpscr->ffcs[i];
12499 916595 newcombo const& cmb = combobuf[ffc.getData()];
12500
3/4
✓ Branch 0 taken 1596 times.
✓ Branch 1 taken 914999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 916595 times.
916595 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12501 914999 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12502 {
12503 do_trigger_combo_ffc(i);
12504 break;
12505 }
12506 916595 }
12507 156560 }
12508 3712135 }
12509
12510 6199104 void do_lens()
12511 {
12512
2/2
✓ Branch 0 taken 2486969 times.
✓ Branch 1 taken 3712135 times.
6199104 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
12513 {
12514 2486969 do_210_lens();
12515 2486969 return;
12516 }
12517
12518 3712135 int32_t wpnPressed = getWpnPressed(itype_lens);
12519
6/6
✓ Branch 0 taken 6256 times.
✓ Branch 1 taken 3705879 times.
✓ Branch 2 taken 375 times.
✓ Branch 3 taken 3705504 times.
✓ Branch 4 taken 390142 times.
✓ Branch 5 taken 3315362 times.
3712135 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
12520
2/2
✓ Branch 0 taken 2781821 times.
✓ Branch 1 taken 930314 times.
3712135 if(itemid >= 0)
12521 {
12522
8/10
✓ Branch 0 taken 5343 times.
✓ Branch 1 taken 924971 times.
✓ Branch 2 taken 5343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 4650 times.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 527 times.
930314 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
12523 {
12524
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 209 times.
527 if(lensid<0)
12525 {
12526 209 lensid=itemid;
12527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(itemsbuf[itemid].family == itype_lens)
12528 209 Hero.setLastLensID(itemid);
12529
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 12 times.
209 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12530 209 }
12531
12532 527 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
12533
12534
2/10
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 527 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
527 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12535 {
12536 //clear the item script stack for a new script
12537 //itemScriptData[(itemid & 0xFFF)].Clear();
12538 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12539 ri = &(itemScriptData[itemid]);
12540 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12541 ri->Clear();
12542 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12543 item_doscript[itemid] = 1;
12544 itemscriptInitialised[itemid] = 0;
12545 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12546 did_scriptl=true;
12547 }
12548
12549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12550 527 else lensclk = 12;
12551 527 }
12552 else
12553 {
12554 929787 did_scriptl=false;
12555
2/2
✓ Branch 0 taken 5732 times.
✓ Branch 1 taken 924055 times.
929787 if(!lensclk)
12556 {
12557
12558
2/2
✓ Branch 0 taken 923849 times.
✓ Branch 1 taken 206 times.
924055 if(lensid>-1)
12559 {
12560 206 lensid=-1;
12561 206 lensclk = 0;
12562
12563
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 11 times.
206 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12564 206 }
12565 924055 }
12566 }
12567 930314 }
12568 3712135 handle_lens_triggers(lensid);
12569 6199104 }
12570 //Add 2.10 version check to call this
12571 2486969 void do_210_lens()
12572 {
12573
3/4
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 2485289 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2485289 times.
2486969 int32_t itemid = lensid >= 0 ? lensid : directWpn>-1 ? directWpn : current_item_id(itype_lens);
12574
12575
2/2
✓ Branch 0 taken 367843 times.
✓ Branch 1 taken 2119126 times.
2486969 if(itemid<0)
12576 2119126 return;
12577
12578
6/8
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 366163 times.
✓ Branch 2 taken 1680 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✓ Branch 5 taken 1432 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 248 times.
367843 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
12579 {
12580
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 234 times.
248 if(lensid<0)
12581 {
12582 234 lensid=itemid;
12583
12584
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12585 234 }
12586
12587 248 paymagiccost(itemid, true);
12588
12589
2/10
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
248 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12590 {
12591 //clear the item script stack for a new script
12592 //itemScriptData[(itemid & 0xFFF)].Clear();
12593 ri = &(itemScriptData[itemid]);
12594 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12595 ri->Clear();
12596 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12597 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12598 item_doscript[itemid] = 1;
12599 itemscriptInitialised[itemid] = 0;
12600 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12601 did_scriptl=true;
12602 }
12603
12604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12605 248 else lensclk = 12;
12606 248 }
12607 else
12608 {
12609 367595 did_scriptl=false;
12610
12611
6/8
✓ Branch 0 taken 1666 times.
✓ Branch 1 taken 365929 times.
✓ Branch 2 taken 1432 times.
✓ Branch 3 taken 234 times.
✓ Branch 4 taken 1432 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1432 times.
✗ Branch 7 not taken.
367595 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
12612 {
12613 234 lensid=-1;
12614 234 lensclk = 0;
12615
12616
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12617 234 }
12618 }
12619 2486969 }
12620
12621 6123 void HeroClass::do_hopping()
12622 {
12623 6123 do_lens();
12624
12625
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 5951 times.
6123 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
12626 //Possible fix for exiting water in diagonal movement. -Z
12627 {
12628 172 int32_t flippers_id = current_item_id(itype_flippers);
12629
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 169 times.
172 if(diveclk>0)
12630 {
12631 3 --diveclk;
12632
2/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
12633 {
12634 diveclk = itemsbuf[flippers_id].misc2;
12635 }
12636 3 }
12637
1/2
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
169 else if(DrunkrAbtn())
12638 {
12639 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
12640 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
12641
12642 if(global_diving==screen_diving)
12643 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
12644 }
12645
12646
3/8
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
172 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
12647 {
12648 172 SetSwim();
12649 172 hopclk = 0;
12650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172 times.
172 if (!IsSideSwim())
12651 {
12652 172 charging = attackclk = 0;
12653 172 tapping = false;
12654 172 }
12655 172 }
12656 else
12657 {
12658 herostep();
12659
12660 if(!isDiving() || (frame&1))
12661 {
12662 switch(dir)
12663 {
12664 case up:
12665 y -= 1;
12666 break;
12667
12668 case down:
12669 y += 1;
12670 break;
12671
12672 case left:
12673 x -= 1;
12674 break;
12675
12676 case right:
12677 x += 1;
12678 break;
12679 }
12680 }
12681 }
12682 172 }
12683 else // hopping in or out (need to separate the cases...)
12684 {
12685
4/6
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 5850 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5850 times.
5951 if((diagonalMovement||NO_GRIDLOCK))
12686 {
12687
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 73 times.
101 if(hopclk==1) //hopping out
12688 //>= 1 possible fix for getting stuck on land edges.
12689 //No, this is not a clock. it's a type. 1 == out, 2 == in.
12690 {
12691
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(hopdir!=-1) dir=hopdir;
12692
12693 73 landswim=0;
12694
12695
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 43 times.
73 if(dir==up)
12696 {
12697 43 herostep();
12698 43 herostep();
12699 43 int32_t sidestep=0;
12700
12701
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 43 times.
43 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12702 sidestep=1;
12703
3/6
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 43 times.
✗ Branch 5 not taken.
43 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12704 sidestep=2;
12705
12706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(sidestep==1) x++;
12707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 else if(sidestep==2) x--;
12708 43 else y--;
12709
12710
3/4
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 3 times.
43 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12711 {
12712 3 hopclk=0;
12713 3 diveclk=0;
12714 3 action=none; FFCore.setHeroAction(none);
12715 3 hopdir=-1;
12716 3 }
12717 43 }
12718
12719
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 30 times.
73 if(dir==down)
12720 {
12721 30 herostep();
12722 30 herostep();
12723 30 int32_t sidestep=0;
12724
12725
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
30 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12726 sidestep=1;
12727
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12728 sidestep=2;
12729
12730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(sidestep==1) x++;
12731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 else if(sidestep==2) x--;
12732 30 else y++;
12733
12734
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
30 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12735 {
12736 2 hopclk=0;
12737 2 diveclk=0;
12738 2 action=none; FFCore.setHeroAction(none);
12739 2 hopdir=-1;
12740 2 }
12741 30 }
12742
12743
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(dir==left)
12744 {
12745 herostep();
12746 herostep();
12747 int32_t sidestep=0;
12748
12749 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12750 sidestep=1;
12751 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12752 sidestep=2;
12753
12754 if(sidestep==1) y++;
12755 else if(sidestep==2) y--;
12756 else x--;
12757
12758 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12759 {
12760 hopclk=0;
12761 diveclk=0;
12762 action=none; FFCore.setHeroAction(none);
12763 hopdir=-1;
12764 }
12765 }
12766
12767
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(dir==right)
12768 {
12769 herostep();
12770 herostep();
12771 int32_t sidestep=0;
12772
12773 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12774 sidestep=1;
12775 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12776 sidestep=2;
12777
12778 if(sidestep==1) y++;
12779 else if(sidestep==2) y--;
12780 else x++;
12781
12782 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12783 {
12784 hopclk=0;
12785 diveclk=0;
12786 action=none; FFCore.setHeroAction(none);
12787 hopdir=-1;
12788 }
12789 }
12790 73 }
12791
12792
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 28 times.
101 if(hopclk==2) //hopping in
12793 {
12794 28 landswim=0;
12795
12796
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(dir==up)
12797 {
12798 14 herostep();
12799 14 herostep();
12800 14 int32_t sidestep=0;
12801
12802
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12803 sidestep=1;
12804
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
14 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12805 sidestep=2;
12806
12807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(sidestep==1) x++;
12808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(sidestep==2) x--;
12809 14 else y--;
12810
12811
3/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 1 times.
14 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12812 {
12813 1 hopclk=0xFF;
12814 1 diveclk=0;
12815 1 SetSwim();
12816 1 }
12817 14 }
12818
12819
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(dir==down)
12820 {
12821 herostep();
12822 herostep();
12823 int32_t sidestep=0;
12824
12825 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12826 sidestep=1;
12827 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12828 sidestep=2;
12829
12830 if(sidestep==1) x++;
12831 else if(sidestep==2) x--;
12832 else y++;
12833
12834 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12835 {
12836 hopclk=0xFF;
12837 diveclk=0;
12838 SetSwim();
12839 if (!IsSideSwim()) reset_swordcharge();
12840 }
12841 }
12842
12843
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(dir==left)
12844 {
12845 herostep();
12846 herostep();
12847 int32_t sidestep=0;
12848
12849 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12850 sidestep=1;
12851 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12852 sidestep=2;
12853
12854 if(sidestep==1) y++;
12855 else if(sidestep==2) y--;
12856 else x--;
12857
12858 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12859 {
12860 hopclk=0xFF;
12861 diveclk=0;
12862 SetSwim();
12863 }
12864 }
12865
12866
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(dir==right)
12867 {
12868 14 herostep();
12869 14 herostep();
12870
12871 14 int32_t sidestep=0;
12872
12873
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12874 sidestep=1;
12875
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
14 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12876 sidestep=2;
12877
12878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(sidestep==1) y++;
12879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(sidestep==2) y--;
12880 14 else x++;
12881
12882
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
14 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12883 {
12884 1 hopclk=0xFF;
12885 1 diveclk=0;
12886 1 SetSwim();
12887 1 }
12888 14 }
12889 28 }
12890
12891 101 }
12892 else
12893 {
12894
7/8
✓ Branch 0 taken 2193 times.
✓ Branch 1 taken 3657 times.
✓ Branch 2 taken 2193 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1624 times.
✓ Branch 5 taken 569 times.
✓ Branch 6 taken 310 times.
✓ Branch 7 taken 3347 times.
5850 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
12895 {
12896 569 action=none; FFCore.setHeroAction(none);
12897 569 hopclk = 0;
12898 569 diveclk = 0;
12899
12900
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 292 times.
569 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
12901 {
12902 // hopped in
12903 292 SetSwim();
12904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
292 if (!IsSideSwim()) attackclk = charging = spins = 0;
12905 292 }
12906 569 }
12907 else
12908 {
12909 5281 herostep();
12910 5281 herostep();
12911
12912
2/2
✓ Branch 0 taken 4972 times.
✓ Branch 1 taken 309 times.
5281 if(++hero_count>(16*hero_animation_speed))
12913 309 hero_count=0;
12914
12915 5281 int32_t xofs2 = x.getInt()&15;
12916 5281 int32_t yofs2 = y.getInt()&15;
12917 5281 int32_t s = 1 + (frame&1);
12918
12919
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 733 times.
✓ Branch 2 taken 1201 times.
✓ Branch 3 taken 1561 times.
✓ Branch 4 taken 1786 times.
5281 switch(dir)
12920 {
12921 case up:
12922
3/4
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 214 times.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
733 if(yofs2<3 || yofs2>13) --y;
12923 519 else y-=s;
12924
12925 733 break;
12926
12927 case down:
12928
4/4
✓ Branch 0 taken 999 times.
✓ Branch 1 taken 202 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 840 times.
1201 if(yofs2<3 || yofs2>13) ++y;
12929 840 else y+=s;
12930
12931 1201 break;
12932
12933 case left:
12934
4/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 260 times.
✓ Branch 3 taken 1105 times.
1561 if(xofs2<3 || xofs2>13) --x;
12935 1105 else x-=s;
12936
12937 1561 break;
12938
12939 case right:
12940
4/4
✓ Branch 0 taken 1485 times.
✓ Branch 1 taken 301 times.
✓ Branch 2 taken 237 times.
✓ Branch 3 taken 1248 times.
1786 if(xofs2<3 || xofs2>13) ++x;
12941 1248 else x+=s;
12942
12943 1786 break;
12944 }
12945 }
12946 }
12947 }
12948 6123 }
12949
12950 64189 void HeroClass::do_rafting()
12951 {
12952
12953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 if(toogam)
12954 {
12955 action=none; FFCore.setHeroAction(none);
12956 return;
12957 }
12958
12959 64189 FFCore.setHeroAction(rafting);
12960
12961 64189 do_lens();
12962
12963 64189 herostep();
12964
12965 //Calculate rafting speed
12966 64189 int32_t raft_item = current_item_id(itype_raft);
12967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
12968 64189 raft_step = vbound(raft_step, -8, 5);
12969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
12970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64189 times.
64189 if(raft_step < 0) raft_step = 1;
12971 64189 int32_t step_inc = 1 << (raft_step - 1);
12972 // Fix position
12973
1/2
✓ Branch 0 taken 64189 times.
✗ Branch 1 not taken.
64189 if(raft_step > 1)
12974 {
12975 if(x.getInt() & (step_inc-1))
12976 {
12977 x = x.getInt() & ~(step_inc-1);
12978 }
12979 if(y.getInt() & (step_inc-1))
12980 {
12981 y = y.getInt() & ~(step_inc-1);
12982 }
12983 }
12984 // Inc clock, check if we need to move this frame
12985 64189 ++raftclk;
12986
2/4
✓ Branch 0 taken 64189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64189 times.
64189 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
12987
12988
4/4
✓ Branch 0 taken 30394 times.
✓ Branch 1 taken 33795 times.
✓ Branch 2 taken 26029 times.
✓ Branch 3 taken 4365 times.
68441 if(!(x.getInt()&15) && !(y.getInt()&15))
12989 {
12990 // this sections handles switching to raft branches
12991
3/4
✓ Branch 0 taken 4144 times.
✓ Branch 1 taken 221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4144 times.
4365 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
12992 {
12993
7/8
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 120 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
221 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12994 {
12995 34 dir = up;
12996 34 goto skip;
12997 }
12998
12999
7/8
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
187 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13000 {
13001 34 dir = down;
13002 34 goto skip;
13003 }
13004
13005
7/8
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 94 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
153 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13006 {
13007 19 dir = left;
13008 19 goto skip;
13009 }
13010
13011
7/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
134 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13012 {
13013 26 dir = right;
13014 26 goto skip;
13015 }
13016 108 }
13017
2/4
✓ Branch 0 taken 4144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4144 times.
4144 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
13018 {
13019 if(dir == left) dir = right;
13020 else if(dir == right) dir = left;
13021 else if(dir == up) dir = down;
13022 else if(dir == down) dir = up;
13023 }
13024
13025
13026
3/4
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 3395 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 857 times.
4252 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
13027 {
13028
2/2
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 405 times.
857 if(dir<left) //going up or down
13029 {
13030
3/4
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
452 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13031 176 dir=right;
13032
3/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
276 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13033 160 dir=left;
13034
4/4
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 7 times.
116 else if(y>0 && y<160)
13035 {
13036 102 action=none; FFCore.setHeroAction(none);
13037 102 x = x.getInt();
13038 102 y = y.getInt();
13039 102 }
13040 452 }
13041 else //going left or right
13042 {
13043
3/4
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 239 times.
405 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13044 166 dir=down;
13045
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
239 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13046 162 dir=up;
13047
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 else if(x>0 && x<240)
13048 {
13049 77 action=none; FFCore.setHeroAction(none);
13050 77 x = x.getInt();
13051 77 y = y.getInt();
13052 77 }
13053 }
13054 857 }
13055 4252 }
13056
13057 skip:
13058
13059
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14264 times.
✓ Branch 2 taken 13696 times.
✓ Branch 3 taken 16866 times.
✓ Branch 4 taken 19363 times.
64189 switch(dir)
13060 {
13061 case up:
13062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14264 times.
14264 if(x.getInt()&15)
13063 {
13064 if(x.getInt()&8)
13065 x++;
13066 else x--;
13067 }
13068 14264 else y -= step_inc;
13069
13070 14264 break;
13071
13072 case down:
13073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13696 times.
13696 if(x.getInt()&15)
13074 {
13075 if(x.getInt()&8)
13076 x++;
13077 else x--;
13078 }
13079 13696 else y += step_inc;
13080
13081 13696 break;
13082
13083 case left:
13084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16866 times.
16866 if(y.getInt()&15)
13085 {
13086 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
13087 {
13088 if ((y.getInt() % 16) < 4) y--;
13089 else y++;
13090 }
13091 else
13092 {
13093 if(y.getInt()&8)
13094 y++;
13095 else y--;
13096 }
13097 }
13098 16866 else x -= step_inc;
13099
13100 16866 break;
13101
13102 case right:
13103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19363 times.
19363 if(y.getInt()&15)
13104 {
13105 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
13106 {
13107 if ((y.getInt() % 16) <= 4) y--;
13108 else y++;
13109 }
13110 else
13111 {
13112 if(y.getInt()&8)
13113 y++;
13114 else y--;
13115 }
13116 }
13117 19363 else x += step_inc;
13118
13119 19363 break;
13120 }
13121 64189 }
13122
13123 9 bool HeroClass::try_hover()
13124 {
13125
6/10
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
9 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
13126 {
13127 2 int32_t itemid = current_item_id(itype_hoverboots);
13128
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hoverclk < 0)
13129 hoverclk = -hoverclk;
13130 else
13131 {
13132 2 fall = fakefall = jumping = 0;
13133
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].misc1)
13134 2 hoverclk = itemsbuf[itemid].misc1;
13135 else
13136 {
13137 hoverclk = 1;
13138 hoverflags |= HOV_INF;
13139 }
13140
13141
13142 2 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
13143 }
13144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[itemid].wpn)
13145
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 decorations.add(new dHover(x, y, dHOVER, 0));
13146 2 return true;
13147 }
13148 7 return false;
13149 9 }
13150
13151 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
13152 //Returns '-1' if not being pulled
13153 //Returns '-2' if should be falling in
13154 24001913 int32_t HeroClass::check_pitslide(bool ignore_hover)
13155 {
13156 //Pitfall todo -Emily
13157 //Iron boots; can't fight slipping, 2px/frame
13158 //Scripted variables to read pull dir/clk (clk only for non-hero)
13159 //Implement falling for all sprite types (npc AI)
13160 // Fall/slipping tiles for enemies
13161 // Fall/slipping SFX for enemies
13162 // Fall SFX for items/weapons
13163 // Weapons/Misc sprite shared for falling items/weapons
13164 //Maybe slip SFX for Hero?
13165 // Weapons/Misc sprite override for falling sprite?
13166 //Update std.zh with relevant new stuff
13167
2/2
✓ Branch 0 taken 1038540 times.
✓ Branch 1 taken 22963373 times.
24001913 if(can_pitfall(ignore_hover))
13168 {
13169
2/2
✓ Branch 0 taken 1797020 times.
✓ Branch 1 taken 21166353 times.
22963373 bool can_diag = (diagonalMovement || get_bit(quest_rules,qr_DISABLE_4WAY_GRIDLOCK));
13170 22963373 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
13171 22963373 int32_t ispitbl = getpitfall(x,y+15);
13172 22963373 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
13173 22963373 int32_t ispitbr = getpitfall(x+15,y+15);
13174 22963373 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
13175 22963373 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
13176 22963373 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
13177 22963373 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
13178 22963373 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
13179 22963373 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13180 22963373 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13181 22963373 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13182 static const int32_t flag_pit_irresistable = (1<<24);
13183
5/5
✓ Branch 0 taken 22957117 times.
✓ Branch 1 taken 472 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 2969 times.
✓ Branch 4 taken 2706 times.
22963373 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13184 {
13185 472 case 4: return -2; //Fully over pit; fall in
13186 case 3:
13187 {
13188
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
109 if(ispitul && ispitur && ispitbl) //UL_3
13189 {
13190
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(ispitul_50)
13191 {
13192
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13193 6 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13194 }
13195 }
13196
3/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 else if(ispitul && ispitur && ispitbr) //UR_3
13197 {
13198 if(ispitur_50)
13199 {
13200 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13201 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13202 }
13203 }
13204
4/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 83 times.
87 else if(ispitul && ispitbl && ispitbr) //BL_3
13205 {
13206
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 74 times.
83 if(ispitbl_50)
13207 {
13208
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
9 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13209 9 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13210 }
13211 74 }
13212
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 else if(ispitbl && ispitur && ispitbr) //BR_3
13213 {
13214
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(ispitbr_50)
13215 {
13216
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13217 4 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13218 }
13219 }
13220 74 break;
13221 }
13222 case 2:
13223 {
13224
4/4
✓ Branch 0 taken 1306 times.
✓ Branch 1 taken 1663 times.
✓ Branch 2 taken 1303 times.
✓ Branch 3 taken 3 times.
2969 if(ispitul && ispitur) //Up
13225 {
13226
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(DrunkDown())
13227 {
13228
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(ispitul_75 && ispitur_75) //Straight up
13229 {
13230 return up | flag_pit_irresistable | (ispitul << 8);
13231 }
13232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(ispitul_75)
13233 {
13234 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
13235 }
13236
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if(ispitur_75)
13237 {
13238 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
13239 }
13240 3 else return -1;
13241 }
13242 else
13243 {
13244 if(ispitul_50 && ispitur_50) //Straight up
13245 {
13246 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13247 }
13248 else if(ispitul_50)
13249 {
13250 if(DrunkRight() && !ispitul_75) return -1;
13251 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13252 }
13253 else if(ispitur_50)
13254 {
13255 if(DrunkLeft() && !ispitur_75) return -1;
13256 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13257 }
13258 }
13259 }
13260
4/4
✓ Branch 0 taken 1605 times.
✓ Branch 1 taken 1361 times.
✓ Branch 2 taken 1303 times.
✓ Branch 3 taken 302 times.
2966 else if(ispitbl && ispitbr) //Down
13261 {
13262
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 290 times.
302 if(DrunkUp())
13263 {
13264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(ispitbl_75 && ispitbr_75) //Straight down
13265 {
13266 return down | flag_pit_irresistable | (ispitbl << 8);
13267 }
13268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbl_75)
13269 {
13270 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
13271 }
13272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbr_75)
13273 {
13274 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
13275 }
13276 12 else return -1;
13277 }
13278 else
13279 {
13280
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
290 if(ispitbl_50 && ispitbr_50) //Straight down
13281 {
13282 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
13283 }
13284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 else if(ispitbl_50)
13285 {
13286 if(DrunkRight() && !ispitbl_75) return -1;
13287 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13288 }
13289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 else if(ispitbr_50)
13290 {
13291 if(DrunkLeft() && !ispitbr_75) return -1;
13292 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13293 }
13294 }
13295 290 }
13296
3/4
✓ Branch 0 taken 1303 times.
✓ Branch 1 taken 1361 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1303 times.
2664 else if(ispitbl && ispitul) //Left
13297 {
13298
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1161 times.
1303 if(DrunkRight())
13299 {
13300
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
142 if(ispitul_75 && ispitbl_75) //Straight left
13301 {
13302 return left | flag_pit_irresistable | (ispitul << 8);
13303 }
13304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(ispitul_75)
13305 {
13306 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13307 }
13308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(ispitbl_75)
13309 {
13310 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13311 }
13312 142 else return -1;
13313 }
13314 else
13315 {
13316
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
1161 if(ispitul_50 && ispitbl_50) //Straight left
13317 {
13318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13319 }
13320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 else if(ispitul_50)
13321 {
13322 if(DrunkDown() && !ispitul_75) return -1;
13323 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13324 }
13325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 else if(ispitbl_50)
13326 {
13327 if(DrunkUp() && !ispitbl_75) return -1;
13328 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13329 }
13330 }
13331 1140 }
13332
2/4
✓ Branch 0 taken 1361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1361 times.
1361 else if(ispitbr && ispitur) //Right
13333 {
13334
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 1232 times.
1361 if(DrunkLeft())
13335 {
13336
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
129 if(ispitur_75 && ispitbr_75) //Straight right
13337 {
13338 6 return right | flag_pit_irresistable | (ispitur << 8);
13339 }
13340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 else if(ispitur_75)
13341 {
13342 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13343 }
13344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 else if(ispitbr_75)
13345 {
13346 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13347 }
13348 123 else return -1;
13349 }
13350 else
13351 {
13352
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1208 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
1232 if(ispitur_50 && ispitbr_50) //Straight right
13353 {
13354
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 16 times.
24 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13355 }
13356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
1208 else if(ispitur_50)
13357 {
13358 if(DrunkDown() && !ispitur_75) return -1;
13359 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13360 }
13361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
1208 else if(ispitbr_50)
13362 {
13363 if(DrunkUp() && !ispitbr_75) return -1;
13364 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13365 }
13366 }
13367 1208 }
13368 2638 break;
13369 }
13370 case 1:
13371 {
13372
3/4
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 1765 times.
✓ Branch 2 taken 941 times.
✗ Branch 3 not taken.
2706 if(ispitul && ispitul_50) //UL_1
13373 {
13374 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13375 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13376 }
13377
4/4
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 2246 times.
✓ Branch 2 taken 444 times.
✓ Branch 3 taken 16 times.
2706 if(ispitur && ispitur_50) //UR_1
13378 {
13379
2/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13380 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13381 }
13382
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
2690 if(ispitbl && ispitbl_50) //BL_1
13383 {
13384 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13385 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13386 }
13387
3/4
✓ Branch 0 taken 1129 times.
✓ Branch 1 taken 1561 times.
✓ Branch 2 taken 1129 times.
✗ Branch 3 not taken.
2690 if(ispitbr && ispitbr_50) //BR_1
13388 {
13389 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13390 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13391 }
13392 2690 break;
13393 }
13394 }
13395 22962519 }
13396 24001059 return -1;
13397 24001913 }
13398
13399 5369238 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13400 {
13401 5369238 pitfall();
13402
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5369236 times.
5369238 if(fallclk) return true;
13403 5369236 int32_t val = check_pitslide();
13404 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13405
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5369230 times.
5369236 if(val == -1)
13406 {
13407 5369230 pit_pulldir = -1;
13408 5369230 pit_pullclk = 0;
13409 5369230 return false;
13410 }
13411 6 int32_t dir = val&0xFF;
13412 6 int32_t cmbid = (val&0xFFFF00)>>8;
13413 6 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13415 {
13416 pit_pulldir = -1;
13417 pit_pullclk = 0;
13418 return false;
13419 }
13420
4/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2 times.
6 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13421 {
13422 2 pit_pulldir = -1;
13423 2 pit_pullclk = 0;
13424 2 return false;
13425 }
13426 4 pit_pulldir = dir;
13427 4 int32_t step = 1;
13428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(sensitivity == 0)
13429 {
13430 4 step = 2;
13431 4 sensitivity = 1;
13432 4 }
13433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(pit_pullclk++ % sensitivity) //No pull this frame
13434 return (val&0x100);
13435
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4 times.
11 for(; step > 0 && !fallclk; --step)
13436 {
13437
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 switch(dir)
13438 {
13439 case l_up: case l_down: case left:
13440 --x; break;
13441 case r_up: case r_down: case right:
13442 7 ++x; break;
13443 }
13444
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
7 switch(dir)
13445 {
13446 case l_up: case r_up: case up:
13447 --y; break;
13448 case l_down: case r_down: case down:
13449 ++y; break;
13450 }
13451 7 pitfall();
13452 7 }
13453
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 return fallclk || (val&0x100);
13454 5369238 }
13455
13456 5369455 void HeroClass::pitfall()
13457 {
13458
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 5369245 times.
5369455 if(fallclk)
13459 {
13460 210 drop_liftwpn();
13461
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
210 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
13462 //Handle falling
13463
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 3 times.
210 if(!--fallclk)
13464 {
13465 3 int32_t dmg = game->get_hp_per_heart()/4;
13466 3 bool dmg_perc = false;
13467 3 bool warp = false;
13468
13469 3 action=none; FFCore.setHeroAction(none);
13470
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
13471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(cmb)
13472 {
13473 3 dmg = cmb->attributes[0]/10000L;
13474 3 dmg_perc = cmb->usrflags&cflag3;
13475 3 warp = cmb->usrflags&cflag1;
13476 3 }
13477
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(cheat_superman && dmg > 0)
13478 dmg = 0;
13479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg) //Damage
13480 {
13481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
13482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
13483 3 }
13484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(warp) //Warp
13485 {
13486 sdir = dir;
13487 if(cmb->usrflags&cflag2) //Direct Warp
13488 {
13489 didpit=true;
13490 pitx=x;
13491 pity=y;
13492 }
13493 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
13494 }
13495 else //Reset to screen entry
13496 {
13497 3 go_respawn_point();
13498 }
13499 3 }
13500 210 }
13501
2/2
✓ Branch 0 taken 329280 times.
✓ Branch 1 taken 5039965 times.
5369245 else if(can_pitfall())
13502 {
13503 5039965 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
13504 5039965 bool ispitbl = ispitfall(x,y+15);
13505 5039965 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
13506 5039965 bool ispitbr = ispitfall(x+15,y+15);
13507 5039965 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
13508
9/10
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 5039484 times.
✓ Branch 2 taken 264 times.
✓ Branch 3 taken 217 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 258 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
5039965 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
13509 {
13510
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
13511
3/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
3 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
13512 3 fallclk = PITFALL_FALL_FRAMES;
13513 3 fallCombo = pitctr;
13514 3 action=falling; FFCore.setHeroAction(falling);
13515 3 spins = 0;
13516 3 charging = 0;
13517 3 drop_liftwpn();
13518 3 }
13519 5039965 }
13520 5369455 }
13521
13522 11473 void HeroClass::mod_steps(std::vector<zfix*>& v)
13523 {
13524
3/4
✓ Branch 0 taken 11109 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 11109 times.
✗ Branch 3 not taken.
11473 bool can_combo = ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS);
13525
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22946 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1) && can_combo) ||
13526
5/6
✓ Branch 0 taken 7802 times.
✓ Branch 1 taken 3671 times.
✓ Branch 2 taken 2164 times.
✓ Branch 3 taken 5638 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7802 times.
11473 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1));
13527 //!DIMITODO: add QR for slow combos under hero
13528
1/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11473 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
13529 {
13530 if(tmpscr2[i].valid!=0)
13531 {
13532 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
13533 {
13534 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
13535 {
13536 slowcombo = false;
13537 break;
13538 }
13539 }
13540 else
13541 {
13542 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
13543 {
13544 slowcombo = false;
13545 break;
13546 }
13547 }
13548 }
13549 }
13550
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
13551 11473 bool is_swimming = (action == swimming);
13552 11473 int32_t shieldid = getCurrentActiveShield();
13553
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 if(shieldid > -1)
13554 {
13555 itemdata const& shield = itemsbuf[shieldid];
13556 if(shield.flags & ITEM_FLAG10) //Change Speed flag
13557 {
13558 zfix perc = shield.misc7;
13559 perc /= 100;
13560 if(perc < 0)
13561 perc = (perc*-1)+1;
13562 zfix add(shield.misc8);
13563 add /= 100;
13564 for(zfix* stp : v)
13565 {
13566 zfix& pix = *stp;
13567 pix = (pix * perc) + add;
13568 }
13569 }
13570 }
13571
13572 11473 auto slow_cpos = COMBOPOS(x+7,y+8);
13573
4/4
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 11109 times.
✓ Branch 2 taken 11109 times.
✓ Branch 3 taken 77763 times.
89236 if(can_combo) for(int q = 6; q >= 0; --q)
13574 {
13575 77763 mapscr* m = FFCore.tempScreens[q];
13576
2/2
✓ Branch 0 taken 13780 times.
✓ Branch 1 taken 63983 times.
77763 if(!m->valid) continue;
13577 13780 newcombo const& cmb = combobuf[m->data[slow_cpos]];
13578
13579
2/2
✓ Branch 0 taken 68900 times.
✓ Branch 1 taken 13780 times.
82680 for(zfix* stp : v)
13580 {
13581 68900 zfix& pix = *stp;
13582 68900 pix *= cmb.speed_mult;
13583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68900 times.
68900 if(cmb.speed_div)
13584 68900 pix /= cmb.speed_div;
13585 68900 pix += cmb.speed_add;
13586 }
13587
3/4
✓ Branch 0 taken 2671 times.
✓ Branch 1 taken 11109 times.
✓ Branch 2 taken 2671 times.
✗ Branch 3 not taken.
13780 if(q > 0 && cmb.type == cBRIDGE)
13588 {
13589 if(get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS)
13590 ? !_walkflag_layer(x+7,y+8,1,&(tmpscr2[q-1]))
13591 : _effectflag_layer(x+7,y+8,1,&(tmpscr2[q-1])))
13592 {
13593 break; //Bridge blocks speed change from below it
13594 }
13595 }
13596 24889 }
13597 11473 zfix mult = 1, div = 1;
13598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
11473 if(is_swimming)
13599 {
13600 mult = game->swim_mult;
13601 div = game->swim_div;
13602 }
13603
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11473 else if(slowcharging && slowcombo) //1/2 speed
13604 {
13605 div = 2;
13606 }
13607
2/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11473 times.
11473 else if(slowcharging || slowcombo) //2/3 speed
13608 {
13609 mult = 2;
13610 div = 3;
13611 }
13612
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 if(!div) div = 1;
13613
2/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11473 times.
11473 if(mult != 1 || div != 1)
13614 {
13615 for(zfix* stp : v)
13616 {
13617 zfix& pix = *stp;
13618 pix = ((pix / div) * mult);
13619 }
13620 }
13621 11473 }
13622
13623 6177406 void HeroClass::moveheroOld()
13624 {
13625
2/4
✓ Branch 0 taken 6177406 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6177406 times.
6177406 if(lstunclock || is_conveyor_stunned) return;
13626 6177406 int32_t xoff=x.getInt()&7;
13627 6177406 int32_t yoff=y.getInt()&7;
13628
3/4
✓ Branch 0 taken 6164706 times.
✓ Branch 1 taken 12700 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6164706 times.
6177406 if(NO_GRIDLOCK)
13629 {
13630 12700 xoff = 0;
13631 12700 yoff = 0;
13632 12700 }
13633 6177406 int32_t push=pushing;
13634 6177406 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
13635 6177406 pushing=0;
13636 6177406 zfix temp_step(hero_newstep);
13637 6177406 zfix temp_x(x);
13638 6177406 zfix temp_y(y);
13639
13640 6177406 int32_t flippers_id = current_item_id(itype_flippers);
13641 6177406 itemdata const& itm = itemsbuf[flippers_id];
13642 6177406 byte intbtn = byte(itm.misc3&0xFF);
13643 6177406 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
13644 6177406 bool eatdive = false;
13645
2/2
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 6171887 times.
6177406 if(diveclk>0)
13646 {
13647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5519 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5519 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
13648 5519 --diveclk;
13649
4/8
✓ Branch 0 taken 3688 times.
✓ Branch 1 taken 1831 times.
✓ Branch 2 taken 3688 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3688 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5519 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
13650 {
13651 diveclk = itemsbuf[flippers_id].misc2;
13652 eatdive = true;
13653 }
13654 5519 }
13655
4/4
✓ Branch 0 taken 59148 times.
✓ Branch 1 taken 6112739 times.
✓ Branch 2 taken 59060 times.
✓ Branch 3 taken 88 times.
6171887 else if(action == swimming && dive_pressed)
13656 {
13657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13658 88 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13659
13660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(global_diving==screen_diving)
13661 {
13662
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13663 88 eatdive = true;
13664 88 }
13665 88 }
13666
2/2
✓ Branch 0 taken 6177318 times.
✓ Branch 1 taken 88 times.
6177406 if(eatdive)
13667 88 getIntBtnInput(intbtn, true, true, false, false, false);
13668
13669
2/2
✓ Branch 0 taken 6113217 times.
✓ Branch 1 taken 64189 times.
6177406 if(action==rafting)
13670 {
13671 64189 do_rafting();
13672
13673
2/2
✓ Branch 0 taken 64010 times.
✓ Branch 1 taken 179 times.
64189 if(action==rafting)
13674 {
13675 64010 return;
13676 }
13677
13678
13679 179 set_respawn_point();
13680 179 trySideviewLadder();
13681 179 }
13682
13683 6113396 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
13684 6113396 int32_t btnwpn = -1;
13685
13686 //&0xFFF removes the "bow & arrows" bitmask
13687 //The Quick Sword is allowed to interrupt attacks.
13688
4/4
✓ Branch 0 taken 6008731 times.
✓ Branch 1 taken 104665 times.
✓ Branch 2 taken 3592459 times.
✓ Branch 3 taken 2416272 times.
6113396 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13689
8/8
✓ Branch 0 taken 5349768 times.
✓ Branch 1 taken 763628 times.
✓ Branch 2 taken 5343998 times.
✓ Branch 3 taken 5770 times.
✓ Branch 4 taken 215492 times.
✓ Branch 5 taken 553906 times.
✓ Branch 6 taken 33262 times.
✓ Branch 7 taken 736136 times.
6113396 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
13690 {
13691
2/2
✓ Branch 0 taken 15747 times.
✓ Branch 1 taken 5361513 times.
5377260 if(DrunkrBbtn())
13692 {
13693 15747 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
13694 15747 dowpn = Bwpn&0xFFF;
13695 15747 directWpn = directItemB;
13696 15747 }
13697
2/2
✓ Branch 0 taken 42595 times.
✓ Branch 1 taken 5318918 times.
5361513 else if(DrunkrAbtn())
13698 {
13699 42595 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
13700 42595 dowpn = Awpn&0xFFF;
13701 42595 directWpn = directItemA;
13702 42595 }
13703
4/4
✓ Branch 0 taken 71669 times.
✓ Branch 1 taken 5247249 times.
✓ Branch 2 taken 71662 times.
✓ Branch 3 taken 7 times.
5318918 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
13704 {
13705 7 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
13706 7 dowpn = Xwpn&0xFFF;
13707 7 directWpn = directItemX;
13708 7 }
13709
4/4
✓ Branch 0 taken 71662 times.
✓ Branch 1 taken 5247249 times.
✓ Branch 2 taken 71557 times.
✓ Branch 3 taken 105 times.
5318911 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
13710 {
13711 105 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
13712 105 dowpn = Ywpn&0xFFF;
13713 105 directWpn = directItemY;
13714 105 }
13715
13716
1/2
✓ Branch 0 taken 5377260 times.
✗ Branch 1 not taken.
5377260 if(directWpn > 255) directWpn = 0;
13717
13718 // The Quick Sword only allows repeated sword or wand swings.
13719
7/8
✓ Branch 0 taken 5343998 times.
✓ Branch 1 taken 33262 times.
✓ Branch 2 taken 33262 times.
✓ Branch 3 taken 5343998 times.
✓ Branch 4 taken 32749 times.
✓ Branch 5 taken 513 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5344511 times.
5377260 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
13720 32749 btnwpn=-1;
13721 5377260 }
13722
13723
2/2
✓ Branch 0 taken 317704 times.
✓ Branch 1 taken 5795692 times.
6113396 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
13724
11/12
✓ Branch 0 taken 5725189 times.
✓ Branch 1 taken 388207 times.
✓ Branch 2 taken 5482169 times.
✓ Branch 3 taken 243020 times.
✓ Branch 4 taken 5407553 times.
✓ Branch 5 taken 74616 times.
✓ Branch 6 taken 5364621 times.
✓ Branch 7 taken 42932 times.
✓ Branch 8 taken 40833 times.
✓ Branch 9 taken 5323788 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 40833 times.
6113396 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
13725 {
13726
2/2
✓ Branch 0 taken 1566 times.
✓ Branch 1 taken 39267 times.
40833 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
13727
5/6
✓ Branch 0 taken 40831 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 40816 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
40833 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
13728 {
13729
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40816 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40816 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
13730 {
13731 paymagiccost(attackid,true);
13732 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
13733 }
13734 40816 SetAttack();
13735 40816 attack=wSword;
13736
13737 40816 attackclk=0;
13738
2/2
✓ Branch 0 taken 1551 times.
✓ Branch 1 taken 39265 times.
40816 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
13739
13740
2/10
✓ Branch 0 taken 40816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
40816 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13741 {
13742 if(!checkmagiccost(dowpn))
13743 {
13744 item_error();
13745 }
13746 else
13747 {
13748 //clear the item script stack for a new script
13749
13750 ri = &(itemScriptData[dowpn]);
13751 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13752 ri->Clear();
13753 //itemScriptData[(dowpn & 0xFFF)].Clear();
13754 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13755 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13756 item_doscript[dowpn] = 1;
13757 itemscriptInitialised[dowpn] = 0;
13758 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13759 did_scripta=true;
13760 }
13761 }
13762 40816 }
13763 else
13764 {
13765 17 item_error();
13766 }
13767 40833 }
13768 else
13769 {
13770 6072563 did_scripta=false;
13771 }
13772
13773
6/10
✓ Branch 0 taken 6049194 times.
✓ Branch 1 taken 64202 times.
✓ Branch 2 taken 6049194 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6049194 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6049194 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6049194 times.
6113396 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
13774 {
13775
3/4
✓ Branch 0 taken 975833 times.
✓ Branch 1 taken 5073361 times.
✓ Branch 2 taken 975833 times.
✗ Branch 3 not taken.
6049194 if(DrunkUp() && canSideviewLadder())
13776 {
13777 setOnSideviewLadder(true);
13778 }
13779
3/4
✓ Branch 0 taken 816375 times.
✓ Branch 1 taken 5232819 times.
✓ Branch 2 taken 816375 times.
✗ Branch 3 not taken.
6049194 else if(DrunkDown() && canSideviewLadder(true))
13780 {
13781 y+=1;
13782 setOnSideviewLadder(true);
13783 }
13784 6049194 }
13785
13786 6113396 int32_t wx=x;
13787 6113396 int32_t wy=y;
13788
3/6
✓ Branch 0 taken 4030998 times.
✓ Branch 1 taken 2082398 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6113396 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6113396 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13789 {
13790 if((xoff==0)||diagonalMovement)
13791 {
13792 if(DrunkUp()) dir=up;
13793 if(DrunkDown()) dir=down;
13794 }
13795
13796 if((yoff==0)||diagonalMovement)
13797 {
13798 if(DrunkLeft()) dir=left;
13799 if(DrunkRight()) dir=right;
13800 }
13801 }
13802
13803
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1411711 times.
✓ Branch 2 taken 1195782 times.
✓ Branch 3 taken 1673013 times.
✓ Branch 4 taken 1832890 times.
6113396 switch(dir)
13804 {
13805 case up:
13806 1411711 wy-=16;
13807 1411711 break;
13808
13809 case down:
13810 1195782 wy+=16;
13811 1195782 break;
13812
13813 case left:
13814 1673013 wx-=16;
13815 1673013 break;
13816
13817 case right:
13818 1832890 wx+=16;
13819 1832890 break;
13820 }
13821
13822 6113396 do_lens();
13823
13824 6113396 WalkflagInfo info;
13825
13826 6113396 bool no_jinx = true;
13827
7/8
✓ Branch 0 taken 5725189 times.
✓ Branch 1 taken 388207 times.
✓ Branch 2 taken 16983 times.
✓ Branch 3 taken 5708206 times.
✓ Branch 4 taken 16983 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1084 times.
✓ Branch 7 taken 15899 times.
6113396 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
13828 {
13829 15899 bool paidmagic = false;
13830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15899 times.
15899 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
13831
7/10
✓ Branch 0 taken 15899 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14363 times.
✓ Branch 3 taken 1536 times.
✓ Branch 4 taken 489 times.
✓ Branch 5 taken 1047 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 489 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1536 times.
15899 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
13832 {
13833
2/2
✓ Branch 0 taken 489 times.
✓ Branch 1 taken 1047 times.
1536 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
13834 1536 no_jinx = checkitem_jinx(attackid);
13835
3/8
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1536 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1536 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13836 {
13837
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1536 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
13838 paymagiccost(attackid,true);
13839 misc_internal_hero_flags |= LF_PAID_WAND_COST;
13840 }
13841 1536 SetAttack();
13842 1536 attack=wWand;
13843 1536 attackclk=0;
13844 1536 }
13845 else
13846 {
13847 item_error();
13848 }
13849 1536 }
13850
5/8
✓ Branch 0 taken 14363 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 13598 times.
✓ Branch 4 taken 765 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 765 times.
15128 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
13851
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 765 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 763 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
765 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
13852 {
13853 765 no_jinx = checkitem_jinx(dowpn);
13854
3/6
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 765 times.
765 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
13855 {
13856 item_error();
13857 }
13858 else
13859 {
13860 765 paymagiccost(dowpn);
13861 765 paidmagic = true;
13862 765 SetAttack();
13863 765 attack=wHammer;
13864
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 763 times.
765 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
13865 765 attackclk=0;
13866 }
13867 765 }
13868
5/8
✓ Branch 0 taken 13598 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165 times.
✓ Branch 3 taken 12433 times.
✓ Branch 4 taken 1165 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1165 times.
14763 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
13869
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1165 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 997 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
1165 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
13870 {
13871 //checkbunny handled where magic cost is paid
13872
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 168 times.
1165 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
13873 1165 no_jinx = checkitem_jinx(attackid);
13874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1165 times.
1165 if(no_jinx)
13875 {
13876 1165 SetAttack();
13877 1165 attack=wFire;
13878 1165 attackclk=0;
13879 1165 }
13880 1165 }
13881
5/8
✓ Branch 0 taken 12433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 12429 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
12437 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
13882
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
13883 {
13884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
13885 4 no_jinx = checkitem_jinx(attackid);
13886
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13887 {
13888
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
13889 paymagiccost(attackid,true);
13890 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
13891 }
13892 4 SetAttack();
13893 4 attack=wCByrna;
13894 4 attackclk=0;
13895 4 }
13896 else
13897 {
13898 item_error();
13899 }
13900 4 }
13901
2/8
✓ Branch 0 taken 12429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12429 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12429 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
13902 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
13903 {
13904 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
13905 no_jinx = checkitem_jinx(attackid);
13906 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
13907 {
13908 paymagiccost(attackid);
13909 SetAttack();
13910 attack = wBugNet;
13911 attackclk = 0;
13912 sfx(itemsbuf[attackid].usesound);
13913 }
13914 else
13915 {
13916 item_error();
13917 }
13918 }
13919 else
13920 {
13921
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 12352 times.
12429 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
13922 12429 no_jinx = checkitem_jinx(itmid);
13923
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 12415 times.
12429 if(no_jinx)
13924 {
13925 12415 paidmagic = startwpn(itmid);
13926
13927
2/2
✓ Branch 0 taken 10419 times.
✓ Branch 1 taken 1996 times.
12415 if(paidmagic)
13928 {
13929
5/10
✓ Branch 0 taken 10419 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10419 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10419 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10419 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 10419 times.
10419 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
13930 {
13931 ;
13932 }
13933 else
13934 {
13935 10419 SetAttack();
13936 10419 attackclk=0;
13937 10419 attack=none;
13938
13939
2/2
✓ Branch 0 taken 1746 times.
✓ Branch 1 taken 8673 times.
10419 if(btnwpn==itype_brang)
13940 {
13941 8673 attack=wBrang;
13942 8673 }
13943 }
13944 10419 }
13945 else
13946 {
13947 // Weapon not started: directWpn should be reset to prev. value.
13948 1996 directWpn = olddirectwpn;
13949 }
13950 12415 }
13951 }
13952
13953
8/12
✓ Branch 0 taken 15899 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15885 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 866 times.
✓ Branch 5 taken 15019 times.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
15899 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13954 {
13955
3/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 800 times.
800 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
13956 {
13957 item_error();
13958 }
13959 else
13960 {
13961 // Only charge for magic if item's magic cost wasn't already charged
13962 // for the item's main use.
13963
4/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 795 times.
800 if(!paidmagic && attack!=wWand)
13964 795 paymagiccost(dowpn);
13965 //clear the item script stack for a new script
13966 //itemScriptData[(dowpn & 0xFFF)].Clear();
13967 800 ri = &(itemScriptData[dowpn]);
13968
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 800 times.
820000 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13969 800 ri->Clear();
13970 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13971 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13972 800 item_doscript[dowpn] = 1;
13973 800 itemscriptInitialised[dowpn] = 0;
13974 800 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13975 800 did_scriptb=true;
13976 }
13977 800 }
13978
13979
7/12
✓ Branch 0 taken 15885 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 15885 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15885 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15885 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15885 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 15885 times.
15899 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
13980 {
13981 return;
13982 }
13983
2/2
✓ Branch 0 taken 15885 times.
✓ Branch 1 taken 14 times.
15899 if(!no_jinx)
13984 14 did_scriptb = false;
13985 15899 }
13986 else
13987 {
13988 6097497 did_scriptb=false;
13989 }
13990
13991
5/6
✓ Branch 0 taken 5350280 times.
✓ Branch 1 taken 763116 times.
✓ Branch 2 taken 5289804 times.
✓ Branch 3 taken 60476 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5289804 times.
6113396 if(attackclk || action==attacking || action==sideswimattacking)
13992 {
13993
13994
4/8
✓ Branch 0 taken 60476 times.
✓ Branch 1 taken 763116 times.
✓ Branch 2 taken 60476 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60476 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
823592 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13995 {
13996 if((xoff==0)||diagonalMovement)
13997 {
13998 if(DrunkUp()) dir=up;
13999 if(DrunkDown()) dir=down;
14000 }
14001
14002 if((yoff==0)||diagonalMovement)
14003 {
14004 if(DrunkLeft()) dir=left;
14005 if(DrunkRight()) dir=right;
14006 }
14007 }
14008
14009 823592 bool attacked = doattack();
14010
14011 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
14012
10/12
✓ Branch 0 taken 821799 times.
✓ Branch 1 taken 1793 times.
✓ Branch 2 taken 582289 times.
✓ Branch 3 taken 239510 times.
✓ Branch 4 taken 111754 times.
✓ Branch 5 taken 470535 times.
✓ Branch 6 taken 110078 times.
✓ Branch 7 taken 1676 times.
✓ Branch 8 taken 110078 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 110078 times.
823592 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
14013 {
14014
4/4
✓ Branch 0 taken 47006 times.
✓ Branch 1 taken 63072 times.
✓ Branch 2 taken 4695 times.
✓ Branch 3 taken 42311 times.
110078 if((xoff==0)||diagonalMovement)
14015 {
14016
2/2
✓ Branch 0 taken 60798 times.
✓ Branch 1 taken 6969 times.
67767 if(DrunkUp()) dir=up;
14017
14018
2/2
✓ Branch 0 taken 60507 times.
✓ Branch 1 taken 7260 times.
67767 if(DrunkDown()) dir=down;
14019 67767 }
14020
14021
4/4
✓ Branch 0 taken 35391 times.
✓ Branch 1 taken 74687 times.
✓ Branch 2 taken 3273 times.
✓ Branch 3 taken 32118 times.
110078 if((yoff==0)||diagonalMovement)
14022 {
14023
2/2
✓ Branch 0 taken 68675 times.
✓ Branch 1 taken 9285 times.
77960 if(DrunkLeft()) dir=left;
14024
14025
2/2
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 9066 times.
77960 if(DrunkRight()) dir=right;
14026 77960 }
14027 110078 }
14028
14029
9/10
✓ Branch 0 taken 765877 times.
✓ Branch 1 taken 57715 times.
✓ Branch 2 taken 763956 times.
✓ Branch 3 taken 1921 times.
✓ Branch 4 taken 763521 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 759306 times.
✓ Branch 7 taken 4215 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 759306 times.
823592 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
14030 {
14031 759306 return;
14032 }
14033
2/2
✓ Branch 0 taken 6571 times.
✓ Branch 1 taken 57715 times.
64286 else if(!attacked)
14034 {
14035 // Spin attack - change direction
14036
3/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 57467 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
57715 if(spins>1 && attack != wHammer)
14037 {
14038 248 spins--;
14039
14040
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 45 times.
248 if(spins%5==0)
14041 {
14042
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
14043 45 sfx(itemsbuf[id].usesound,pan(x.getInt()));
14044 45 }
14045 248 attackclk=1;
14046
14047
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
248 switch(dir)
14048 {
14049 case up:
14050 62 dir=left;
14051 62 break;
14052
14053 case right:
14054 62 dir=up;
14055 62 break;
14056
14057 case down:
14058 62 dir=right;
14059 62 break;
14060
14061 case left:
14062 62 dir=down;
14063 62 break;
14064 }
14065
14066 248 return;
14067 }
14068 else
14069 {
14070 57467 spins=0;
14071 }
14072
14073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57467 times.
57467 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
14074 57467 else {action=none; FFCore.setHeroAction(none);}
14075 57467 attackclk=0;
14076 57467 charging=0;
14077 57467 }
14078 64038 }
14079
14080
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5353839 times.
5353842 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
14081 3 return;
14082
14083
2/2
✓ Branch 0 taken 2202517 times.
✓ Branch 1 taken 3151322 times.
5353839 if(action==walking) //still walking
14084 {
14085
9/10
✓ Branch 0 taken 2379764 times.
✓ Branch 1 taken 771558 times.
✓ Branch 2 taken 1752394 times.
✓ Branch 3 taken 627370 times.
✓ Branch 4 taken 934209 times.
✓ Branch 5 taken 818185 times.
✓ Branch 6 taken 40979 times.
✓ Branch 7 taken 893230 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 40979 times.
3151322 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
14086 {
14087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40979 times.
40979 if(attackclk>0) SetAttack();
14088 40979 else {action = none; FFCore.setHeroAction(none);}
14089 40979 hero_count=-1;
14090 40979 return;
14091 }
14092
14093 3110343 autostep=false;
14094
14095
4/6
✓ Branch 0 taken 2811474 times.
✓ Branch 1 taken 298869 times.
✓ Branch 2 taken 2811474 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2811474 times.
3110343 if(!(diagonalMovement || NO_GRIDLOCK))
14096 {
14097
2/4
✓ Branch 0 taken 2811474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2811474 times.
2811474 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
14098 {
14099 if(dir==up&&yoff)
14100 {
14101 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
14102 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
14103 execute(info);
14104
14105 if(!info.isUnwalkable())
14106 {
14107 moveOld2(up);
14108 }
14109 else
14110 {
14111 action=none; FFCore.setHeroAction(none);
14112 }
14113
14114 return;
14115 }
14116
14117 if(dir==down&&yoff)
14118 {
14119 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
14120 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
14121 execute(info);
14122
14123 if(!info.isUnwalkable())
14124 {
14125 moveOld2(down);
14126 }
14127 else
14128 {
14129 action=none; FFCore.setHeroAction(none);
14130 }
14131
14132 return;
14133 }
14134
14135 if(dir==left&&xoff)
14136 {
14137 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
14138 execute(info);
14139
14140 if(!info.isUnwalkable())
14141 {
14142 moveOld2(left);
14143 }
14144 else
14145 {
14146 action=none; FFCore.setHeroAction(none);
14147 }
14148
14149 return;
14150 }
14151
14152 if(dir==right&&xoff)
14153 {
14154 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
14155 execute(info);
14156
14157 if(!info.isUnwalkable())
14158 {
14159 moveOld2(right);
14160 }
14161 else
14162 {
14163 action=none; FFCore.setHeroAction(none);
14164 }
14165
14166 return;
14167 }
14168 }
14169 else
14170 {
14171
4/4
✓ Branch 0 taken 651512 times.
✓ Branch 1 taken 2159962 times.
✓ Branch 2 taken 107109 times.
✓ Branch 3 taken 544403 times.
2811474 if(dir==up&&yoff)
14172 {
14173 544403 while(true)
14174 {
14175 544403 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
14176 544403 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
14177 544403 execute(info);
14178
14179
2/2
✓ Branch 0 taken 2253 times.
✓ Branch 1 taken 542150 times.
544403 if(!info.isUnwalkable())
14180 {
14181 542150 hero_newstep = temp_step;
14182 542150 x = temp_x;
14183 542150 y = temp_y;
14184 542150 moveOld2(up);
14185 542150 return;
14186 }
14187 //Could not move, try moving less
14188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2253 times.
2253 if(temp_y != int32_t(temp_y))
14189 {
14190 temp_y = floor((double)temp_y);
14191 continue;
14192 }
14193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2253 times.
2253 else if(temp_step > 1)
14194 {
14195 if(temp_step != int32_t(temp_step)) //floor
14196 temp_step = floor((double)temp_step);
14197 else --temp_step;
14198 continue;
14199 }
14200 else //Can't move less, stop moving
14201 {
14202 2253 action=none; FFCore.setHeroAction(none);
14203 }
14204 2253 return;
14205 }
14206 }
14207
14208
4/4
✓ Branch 0 taken 532460 times.
✓ Branch 1 taken 1734611 times.
✓ Branch 2 taken 88196 times.
✓ Branch 3 taken 444264 times.
2267071 if(dir==down&&yoff)
14209 {
14210 444264 while(true)
14211 {
14212 444270 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
14213 444270 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
14214 444270 execute(info);
14215
14216
2/2
✓ Branch 0 taken 1862 times.
✓ Branch 1 taken 442408 times.
444270 if(!info.isUnwalkable())
14217 {
14218 442408 hero_newstep = temp_step;
14219 442408 x = temp_x;
14220 442408 y = temp_y;
14221 442408 moveOld2(down);
14222 442408 return;
14223 }
14224 //Could not move, try moving less
14225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(temp_y != int32_t(temp_y))
14226 {
14227 temp_y = floor((double)temp_y);
14228 continue;
14229 }
14230
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1856 times.
1862 else if(temp_step > 1)
14231 {
14232
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(temp_step != int32_t(temp_step)) //floor
14233 6 temp_step = floor((double)temp_step);
14234 else --temp_step;
14235 6 continue;
14236 }
14237 else //Can't move less, stop moving
14238 {
14239 1856 action=none; FFCore.setHeroAction(none);
14240 }
14241 1856 return;
14242 }
14243 }
14244
14245
4/4
✓ Branch 0 taken 784904 times.
✓ Branch 1 taken 1037903 times.
✓ Branch 2 taken 131797 times.
✓ Branch 3 taken 653107 times.
1822807 if(dir==left&&xoff)
14246 {
14247 653107 while(true)
14248 {
14249 653107 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
14250 653107 execute(info);
14251
14252
2/2
✓ Branch 0 taken 2018 times.
✓ Branch 1 taken 651089 times.
653107 if(!info.isUnwalkable())
14253 {
14254 651089 hero_newstep = temp_step;
14255 651089 x = temp_x;
14256 651089 y = temp_y;
14257 651089 moveOld2(left);
14258 651089 return;
14259 }
14260 //Could not move, try moving less
14261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2018 times.
2018 if(temp_x != int32_t(temp_x))
14262 {
14263 temp_x = floor((double)temp_x);
14264 continue;
14265 }
14266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2018 times.
2018 else if(temp_step > 1)
14267 {
14268 if(temp_step != int32_t(temp_step)) //floor
14269 temp_step = floor((double)temp_step);
14270 else --temp_step;
14271 continue;
14272 }
14273 else //Can't move less, stop moving
14274 {
14275 2018 action=none; FFCore.setHeroAction(none);
14276 }
14277 2018 return;
14278 }
14279 }
14280
14281
4/4
✓ Branch 0 taken 842598 times.
✓ Branch 1 taken 327102 times.
✓ Branch 2 taken 141165 times.
✓ Branch 3 taken 701433 times.
1169700 if(dir==right&&xoff)
14282 {
14283 701433 while(true)
14284 {
14285 701441 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
14286 701441 execute(info);
14287
14288
2/2
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 699434 times.
701441 if(!info.isUnwalkable())
14289 {
14290 699434 hero_newstep = temp_step;
14291 699434 x = temp_x;
14292 699434 y = temp_y;
14293 699434 moveOld2(right);
14294 699434 return;
14295 }
14296 //Could not move, try moving less
14297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2007 times.
2007 if(temp_x != int32_t(temp_x))
14298 {
14299 temp_x = floor((double)temp_x);
14300 continue;
14301 }
14302
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1999 times.
2007 else if(temp_step > 1)
14303 {
14304
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(temp_step != int32_t(temp_step)) //floor
14305 8 temp_step = floor((double)temp_step);
14306 else --temp_step;
14307 8 continue;
14308 }
14309 else //Can't move less, stop moving
14310 {
14311 1999 action=none; FFCore.setHeroAction(none);
14312 }
14313 1999 return;
14314 }
14315 }
14316 }
14317 468267 }
14318
14319 767136 } // endif (action==walking)
14320
14321
16/24
✓ Branch 0 taken 2905451 times.
✓ Branch 1 taken 64202 times.
✓ Branch 2 taken 2905451 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2905451 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2905451 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2905451 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2905451 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2905451 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2905451 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2905451 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2903530 times.
✓ Branch 19 taken 1921 times.
✓ Branch 20 taken 2903095 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 74093 times.
✓ Branch 23 taken 2829002 times.
2969653 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
14322 {
14323 2829002 action=none; FFCore.setHeroAction(none);
14324 2829002 }
14325
14326
2/2
✓ Branch 0 taken 640054 times.
✓ Branch 1 taken 2329599 times.
2969653 if(diagonalMovement)
14327 {
14328
5/5
✓ Branch 0 taken 242851 times.
✓ Branch 1 taken 59759 times.
✓ Branch 2 taken 44841 times.
✓ Branch 3 taken 134045 times.
✓ Branch 4 taken 158558 times.
640054 switch(holddir)
14329 {
14330 case up:
14331
2/2
✓ Branch 0 taken 57795 times.
✓ Branch 1 taken 1964 times.
59759 if(!Up())
14332 {
14333 1964 holddir=-1;
14334 1964 }
14335
14336 59759 break;
14337
14338 case down:
14339
2/2
✓ Branch 0 taken 43059 times.
✓ Branch 1 taken 1782 times.
44841 if(!Down())
14340 {
14341 1782 holddir=-1;
14342 1782 }
14343
14344 44841 break;
14345
14346 case left:
14347
2/2
✓ Branch 0 taken 129977 times.
✓ Branch 1 taken 4068 times.
134045 if(!Left())
14348 {
14349 4068 holddir=-1;
14350 4068 }
14351
14352 134045 break;
14353
14354 case right:
14355
2/2
✓ Branch 0 taken 154066 times.
✓ Branch 1 taken 4492 times.
158558 if(!Right())
14356 {
14357 4492 holddir=-1;
14358 4492 }
14359
14360 158558 break;
14361
14362 default:
14363 242851 break;
14364 } //end switch
14365
14366
3/4
✓ Branch 0 taken 513820 times.
✓ Branch 1 taken 126234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 513820 times.
640054 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
14367 {
14368 126234 walkable = false;
14369
6/6
✓ Branch 0 taken 22764 times.
✓ Branch 1 taken 103470 times.
✓ Branch 2 taken 22044 times.
✓ Branch 3 taken 720 times.
✓ Branch 4 taken 5926 times.
✓ Branch 5 taken 16118 times.
126234 if(DrunkUp()&&(holddir==-1||holddir==up))
14370 {
14371
4/8
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 16752 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 86 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16838 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14372 {
14373 }
14374 else
14375 {
14376
4/10
✓ Branch 0 taken 16838 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16838 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16838 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16838 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
16838 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14377 {
14378 16838 dir=up;
14379 16838 }
14380
14381 16838 holddir=up;
14382
14383
3/4
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 14873 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1965 times.
16838 if(DrunkRight()&&shiftdir!=left)
14384 {
14385 1965 shiftdir=right;
14386
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1965 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14387
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1965 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14388 1965 }
14389
4/4
✓ Branch 0 taken 2127 times.
✓ Branch 1 taken 12746 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2125 times.
14873 else if(DrunkLeft()&&shiftdir!=right)
14390 {
14391 2125 shiftdir=left;
14392
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2125 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14393
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2125 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14394 2125 }
14395 else
14396 {
14397 12748 shiftdir=-1;
14398 }
14399
14400 //walkable if Ladder can be placed or is already placed vertically
14401
1/20
✗ Branch 0 not taken.
✓ Branch 1 taken 16838 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
16838 if(isSideViewHero() && !toogam && (!get_bit(quest_rules, qr_OLD_LADDER_ITEM_SIDEVIEW) || !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up))) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14402 {
14403 walkable=false;
14404 }
14405 else
14406 {
14407 16838 do
14408 {
14409 19352 zfix ty = y - hero_newstep;
14410 38704 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14411 19352 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14412
14413
3/4
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 19305 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
19352 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14414 {
14415 47 info = info || walkflag(x, zfix(0), 2, up);
14416 47 info = info || walkflag(x+15, zfix(0), 1, up);
14417 47 }
14418 19352 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
14419
14420 19352 execute(info);
14421
14422
2/2
✓ Branch 0 taken 4834 times.
✓ Branch 1 taken 14518 times.
19352 if(info.isUnwalkable())
14423 {
14424
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4640 times.
4834 if(y != y.getInt())
14425 {
14426 194 y.doRound();
14427 194 }
14428
2/2
✓ Branch 0 taken 2320 times.
✓ Branch 1 taken 2320 times.
4640 else if(hero_newstep > 1)
14429 {
14430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2320 times.
2320 if(hero_newstep != int32_t(hero_newstep)) //floor
14431 2320 hero_newstep = floor((double)hero_newstep);
14432 else --hero_newstep;
14433 2320 }
14434 else
14435 2320 break;
14436 2514 }
14437 14518 else walkable = true;
14438
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 14518 times.
17032 }
14439 17032 while(!walkable);
14440 }
14441
14442 16838 int32_t s=shiftdir;
14443
14444
4/6
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 16752 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86 times.
✗ Branch 5 not taken.
16838 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14445 {
14446 shiftdir=-1;
14447 }
14448 else
14449 {
14450
2/2
✓ Branch 0 taken 2125 times.
✓ Branch 1 taken 14713 times.
16838 if(s==left)
14451 {
14452 2125 do
14453 {
14454 2523 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14455
14456 2523 execute(info);
14457
14458
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 1763 times.
2523 if(info.isUnwalkable())
14459 {
14460
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 724 times.
760 if(x != x.getInt())
14461 {
14462 36 x.doRound();
14463 36 }
14464
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 362 times.
724 else if(hero_newstep_diag > 1)
14465 {
14466
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14467 362 hero_newstep_diag.doFloor();
14468 else --hero_newstep_diag;
14469 362 }
14470 else
14471 362 shiftdir = -1;
14472 760 }
14473
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 230 times.
1763 else if(walkable)
14474 {
14475 1533 do
14476 {
14477 1536 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
14478 1536 execute(info);
14479
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1531 times.
1536 if(info.isUnwalkable())
14480 {
14481
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if(x != x.getInt())
14482 {
14483 1 x.doRound();
14484 1 }
14485
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
14486 {
14487
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14488 2 hero_newstep_diag.doFloor();
14489 else --hero_newstep_diag;
14490 2 }
14491 else
14492 2 shiftdir = -1;
14493 5 }
14494 1531 else break;
14495
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 }
14496 5 while(shiftdir != -1);
14497 1533 break;
14498 }
14499 230 else break;
14500
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 362 times.
760 }
14501 760 while(shiftdir != -1);
14502 2125 }
14503
2/2
✓ Branch 0 taken 12748 times.
✓ Branch 1 taken 1965 times.
14713 else if(s==right)
14504 {
14505 1965 do
14506 {
14507 2271 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14508
14509 2271 execute(info);
14510
14511
2/2
✓ Branch 0 taken 577 times.
✓ Branch 1 taken 1694 times.
2271 if(info.isUnwalkable())
14512 {
14513
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 542 times.
577 if(x != x.getInt())
14514 {
14515 35 x.doRound();
14516 35 }
14517
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 271 times.
542 else if(hero_newstep_diag > 1)
14518 {
14519
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14520 271 hero_newstep_diag.doFloor();
14521 else --hero_newstep_diag;
14522 271 }
14523 else
14524 271 shiftdir = -1;
14525 577 }
14526
2/2
✓ Branch 0 taken 1469 times.
✓ Branch 1 taken 225 times.
1694 else if(walkable)
14527 {
14528 1469 do
14529 {
14530 1475 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
14531 1475 execute(info);
14532
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1464 times.
1475 if(info.isUnwalkable())
14533 {
14534
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14535 {
14536 1 x.doRound();
14537 1 }
14538
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14539 {
14540
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14541 5 hero_newstep_diag.doFloor();
14542 else --hero_newstep_diag;
14543 5 }
14544 else
14545 5 shiftdir = -1;
14546 11 }
14547 1464 else break;
14548
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14549 11 while(shiftdir != -1);
14550 1469 break;
14551 }
14552 225 else break;
14553
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 271 times.
577 }
14554 577 while(shiftdir != -1);
14555 1965 }
14556 }
14557
14558 16838 moveOld2(up);
14559 16838 shiftdir=s;
14560
14561
2/2
✓ Branch 0 taken 14518 times.
✓ Branch 1 taken 2320 times.
16838 if(!walkable)
14562 {
14563
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 1794 times.
2320 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14564 {
14565 1794 x = x.getInt();
14566 1794 y = y.getInt();
14567
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1794 times.
✓ Branch 4 taken 1541 times.
✓ Branch 5 taken 253 times.
✓ Branch 6 taken 116 times.
✓ Branch 7 taken 1678 times.
2047 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14568
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 123 times.
253 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14569
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
123 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14570 {
14571
5/8
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 116 times.
116 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
14572 116 sprite::move((zfix)-1,(zfix)0);
14573 116 }
14574 else
14575 {
14576
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1678 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1678 times.
✓ Branch 4 taken 137 times.
✓ Branch 5 taken 1541 times.
✓ Branch 6 taken 126 times.
✓ Branch 7 taken 1552 times.
3219 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14577
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1541 times.
✓ Branch 2 taken 1541 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✓ Branch 5 taken 126 times.
1541 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14578
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14579 {
14580
4/8
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 126 times.
126 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
14581 126 sprite::move((zfix)1,(zfix)0);
14582 126 }
14583 else
14584 {
14585 1552 pushing=push+1;
14586 }
14587 }
14588 1794 }
14589 else
14590 {
14591 526 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14592 }
14593 2320 }
14594
14595 16838 return;
14596 }
14597 }
14598
14599
6/6
✓ Branch 0 taken 21674 times.
✓ Branch 1 taken 87722 times.
✓ Branch 2 taken 20876 times.
✓ Branch 3 taken 798 times.
✓ Branch 4 taken 15551 times.
✓ Branch 5 taken 5325 times.
109396 if(DrunkDown()&&(holddir==-1||holddir==down))
14600 {
14601
4/8
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 16216 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16349 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14602 {
14603 }
14604 else
14605 {
14606
4/10
✓ Branch 0 taken 16349 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16349 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16349 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16349 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
16349 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14607 {
14608 16349 dir=down;
14609 16349 }
14610
14611 16349 holddir=down;
14612
14613
4/4
✓ Branch 0 taken 2434 times.
✓ Branch 1 taken 13915 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2432 times.
16349 if(DrunkRight()&&shiftdir!=left)
14614 {
14615 2432 shiftdir=right;
14616
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2432 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2432 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14617
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2432 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2432 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14618 2432 }
14619
4/4
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 11419 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2497 times.
13917 else if(DrunkLeft()&&shiftdir!=right)
14620 {
14621 2497 shiftdir=left;
14622
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2497 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14623
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2497 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14624 2497 }
14625 else
14626 {
14627 11420 shiftdir=-1;
14628 }
14629
14630 //bool walkable;
14631
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 16349 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
16349 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14632 {
14633 walkable=false;
14634 }
14635 else
14636 {
14637 16349 do
14638 {
14639 18187 info = walkflag(x,15+(y+hero_newstep),2,down);
14640
14641
2/2
✓ Branch 0 taken 10469 times.
✓ Branch 1 taken 7718 times.
18187 if(x.getFloor() & 7)
14642 10469 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
14643 else
14644 7718 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
14645
14646 18187 execute(info);
14647
14648
2/2
✓ Branch 0 taken 3449 times.
✓ Branch 1 taken 14738 times.
18187 if(info.isUnwalkable())
14649 {
14650
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 3234 times.
3449 if(y != y.getInt())
14651 {
14652 215 y.doRound();
14653 215 }
14654
2/2
✓ Branch 0 taken 1623 times.
✓ Branch 1 taken 1611 times.
3234 else if(hero_newstep > 1)
14655 {
14656
1/2
✓ Branch 0 taken 1623 times.
✗ Branch 1 not taken.
1623 if(hero_newstep != int32_t(hero_newstep)) //floor
14657 1623 hero_newstep = floor((double)hero_newstep);
14658 else --hero_newstep;
14659 1623 }
14660 else
14661 1611 break;
14662 1838 }
14663 14738 else walkable = true;
14664
2/2
✓ Branch 0 taken 1838 times.
✓ Branch 1 taken 14738 times.
16576 }
14665 16576 while(!walkable);
14666 }
14667
14668 16349 int32_t s=shiftdir;
14669
14670
4/6
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 16216 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
16349 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14671 {
14672 shiftdir=-1;
14673 }
14674 else
14675 {
14676
2/2
✓ Branch 0 taken 2497 times.
✓ Branch 1 taken 13852 times.
16349 if(s==left)
14677 {
14678 2497 do
14679 {
14680 2882 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14681
14682 2882 execute(info);
14683
14684
2/2
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 2164 times.
2882 if(info.isUnwalkable())
14685 {
14686
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 666 times.
718 if(x != x.getInt())
14687 {
14688 52 x.doRound();
14689 52 }
14690
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 333 times.
666 else if(hero_newstep_diag > 1)
14691 {
14692
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14693 333 hero_newstep_diag.doFloor();
14694 else --hero_newstep_diag;
14695 333 }
14696 else
14697 333 shiftdir = -1;
14698 718 }
14699
2/2
✓ Branch 0 taken 1922 times.
✓ Branch 1 taken 242 times.
2164 else if(walkable)
14700 {
14701 1922 do
14702 {
14703 1929 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
14704 1929 execute(info);
14705
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1919 times.
1929 if(info.isUnwalkable())
14706 {
14707
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if(x != x.getInt())
14708 {
14709 4 x.doRound();
14710 4 }
14711
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14712 {
14713
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14714 3 hero_newstep_diag.doFloor();
14715 else --hero_newstep_diag;
14716 3 }
14717 else
14718 3 shiftdir = -1;
14719 10 }
14720 1919 else break;
14721
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 }
14722 10 while(shiftdir != -1);
14723 1922 break;
14724 }
14725 242 else break;
14726
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 333 times.
718 }
14727 718 while(shiftdir != -1);
14728 2497 }
14729
2/2
✓ Branch 0 taken 11420 times.
✓ Branch 1 taken 2432 times.
13852 else if(s==right)
14730 {
14731 2432 do
14732 {
14733 2758 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14734
14735 2758 execute(info);
14736
14737
2/2
✓ Branch 0 taken 628 times.
✓ Branch 1 taken 2130 times.
2758 if(info.isUnwalkable())
14738 {
14739
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 604 times.
628 if(x != x.getInt())
14740 {
14741 24 x.doRound();
14742 24 }
14743
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 302 times.
604 else if(hero_newstep_diag > 1)
14744 {
14745
1/2
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
302 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14746 302 hero_newstep_diag.doFloor();
14747 else --hero_newstep_diag;
14748 302 }
14749 else
14750 302 shiftdir = -1;
14751 628 }
14752
2/2
✓ Branch 0 taken 1879 times.
✓ Branch 1 taken 251 times.
2130 else if(walkable)
14753 {
14754 1879 do
14755 {
14756 1883 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
14757 1883 execute(info);
14758
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1875 times.
1883 if(info.isUnwalkable())
14759 {
14760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(x != x.getInt())
14761 {
14762 x.doRound();
14763 }
14764
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 else if(hero_newstep_diag > 1)
14765 {
14766
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14767 4 hero_newstep_diag.doFloor();
14768 else --hero_newstep_diag;
14769 4 }
14770 else
14771 4 shiftdir = -1;
14772 8 }
14773 1875 else break;
14774
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 }
14775 8 while(shiftdir != -1);
14776 1879 break;
14777 }
14778 251 else break;
14779
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 302 times.
628 }
14780 628 while(shiftdir != -1);
14781 2432 }
14782 }
14783
14784 16349 moveOld2(down);
14785 16349 shiftdir=s;
14786
14787
2/2
✓ Branch 0 taken 14738 times.
✓ Branch 1 taken 1611 times.
16349 if(!walkable)
14788 {
14789
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 1088 times.
1611 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14790 {
14791 1088 x = x.getInt();
14792 1088 y = y.getInt();
14793
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1088 times.
✓ Branch 2 taken 1088 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 905 times.
✓ Branch 5 taken 183 times.
✓ Branch 6 taken 131 times.
✓ Branch 7 taken 957 times.
1271 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14794
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 183 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 131 times.
183 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
14795
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✓ Branch 2 taken 131 times.
✗ Branch 3 not taken.
131 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14796 {
14797
4/8
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 131 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 131 times.
131 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
14798 131 sprite::move((zfix)-1,(zfix)0);
14799 131 }
14800
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 957 times.
✓ Branch 2 taken 957 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 905 times.
✓ Branch 6 taken 146 times.
✓ Branch 7 taken 811 times.
1862 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14801
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 905 times.
✓ Branch 2 taken 905 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 759 times.
✓ Branch 5 taken 146 times.
905 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
14802
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 146 times.
146 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14803 {
14804
4/8
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 146 times.
146 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
14805 146 sprite::move((zfix)1,(zfix)0);
14806 146 }
14807 else
14808 {
14809 811 pushing=push+1;
14810 }
14811 1088 }
14812 else
14813 {
14814 523 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14815 }
14816 1611 }
14817
14818 16349 return;
14819 }
14820 }
14821
14822
6/6
✓ Branch 0 taken 22794 times.
✓ Branch 1 taken 70253 times.
✓ Branch 2 taken 21950 times.
✓ Branch 3 taken 844 times.
✓ Branch 4 taken 21942 times.
✓ Branch 5 taken 8 times.
93047 if(DrunkLeft()&&(holddir==-1||holddir==left))
14823 {
14824
4/8
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 22729 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
22786 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14825 {
14826 }
14827 else
14828 {
14829
3/6
✓ Branch 0 taken 22786 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22786 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22786 times.
22786 if(charging==0 && spins==0 && action != sideswimattacking)
14830 {
14831 22786 dir=left;
14832 22786 }
14833 22786 sideswimdir = left;
14834
14835 22786 holddir=left;
14836
14837
3/4
✓ Branch 0 taken 3141 times.
✓ Branch 1 taken 19645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3141 times.
22786 if(DrunkUp()&&shiftdir!=down)
14838 {
14839 3141 shiftdir=up;
14840 3141 }
14841
3/4
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 17107 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2538 times.
19645 else if(DrunkDown()&&shiftdir!=up)
14842 {
14843 2538 shiftdir=down;
14844 2538 }
14845 else
14846 {
14847 17107 shiftdir=-1;
14848 }
14849
14850 22786 do
14851 {
14852 25400 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
14853
14854 25400 info = info || walkflag(x-hero_newstep,y+15,1,left);
14855
14856 25400 execute(info);
14857
14858
2/2
✓ Branch 0 taken 5019 times.
✓ Branch 1 taken 20381 times.
25400 if(info.isUnwalkable())
14859 {
14860
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 4810 times.
5019 if(x != x.getInt())
14861 {
14862 209 x.doRound();
14863 209 }
14864
2/2
✓ Branch 0 taken 2405 times.
✓ Branch 1 taken 2405 times.
4810 else if(hero_newstep > 1)
14865 {
14866
1/2
✓ Branch 0 taken 2405 times.
✗ Branch 1 not taken.
2405 if(hero_newstep != int32_t(hero_newstep)) //floor
14867 2405 hero_newstep = floor((double)hero_newstep);
14868 else --hero_newstep;
14869 2405 }
14870 else
14871 2405 break;
14872 2614 }
14873 20381 else walkable = true;
14874
2/2
✓ Branch 0 taken 2614 times.
✓ Branch 1 taken 20381 times.
22995 }
14875 22995 while(!walkable);
14876
14877 22786 int32_t s=shiftdir;
14878
14879
5/14
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 22729 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 22786 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
22786 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14880 {
14881 shiftdir=-1;
14882 }
14883 else
14884 {
14885
2/2
✓ Branch 0 taken 19645 times.
✓ Branch 1 taken 3141 times.
22786 if(s==up)
14886 {
14887 3141 do
14888 {
14889 3611 zfix ty = y - hero_newstep_diag;
14890 7222 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14891 3611 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14892
14893
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
3611 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14894 {
14895 1 info = info || walkflag(x, zfix(0), 2, up);
14896 1 info = info || walkflag(x+15, zfix(0), 1, up);
14897 1 }
14898 3611 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
14899
14900 3611 execute(info);
14901
14902
2/2
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 2716 times.
3611 if(info.isUnwalkable())
14903 {
14904
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 850 times.
895 if(y != y.getInt())
14905 {
14906 45 y.doRound();
14907 45 }
14908
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 425 times.
850 else if(hero_newstep_diag > 1)
14909 {
14910
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14911 425 hero_newstep_diag.doFloor();
14912 else --hero_newstep_diag;
14913 425 }
14914 else
14915 425 shiftdir = -1;
14916 895 }
14917
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 517 times.
2716 else if(walkable)
14918 {
14919 2199 do
14920 {
14921 2221 zfix tx = x-hero_newstep, ty = y-hero_newstep_diag;
14922 2221 info = walkflag(tx,(bigHitbox?0:8)+ty,1,up);
14923
14924
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
2221 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14925 {
14926 1 info = info || walkflag(tx, zfix(0), 1, up);
14927 1 info = info || walkflag(tx+15, zfix(0), 1, up);
14928 1 }
14929 2221 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
14930
14931 2221 execute(info);
14932
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2186 times.
2221 if(info.isUnwalkable())
14933 {
14934
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26 times.
35 if(y != y.getInt())
14935 {
14936 9 y.doRound();
14937 9 }
14938
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 else if(hero_newstep_diag > 1)
14939 {
14940
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14941 13 hero_newstep_diag.doFloor();
14942 else --hero_newstep_diag;
14943 13 }
14944 else
14945 13 shiftdir = -1;
14946 35 }
14947 2186 else break;
14948
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13 times.
35 }
14949 35 while(shiftdir != -1);
14950 2199 break;
14951 }
14952 517 else break;
14953
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 425 times.
895 }
14954 895 while(shiftdir != -1);
14955 3141 }
14956
2/2
✓ Branch 0 taken 17107 times.
✓ Branch 1 taken 2538 times.
19645 else if(s==down)
14957 {
14958 2538 do
14959 {
14960 2973 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14961
14962 2973 execute(info);
14963
14964
2/2
✓ Branch 0 taken 823 times.
✓ Branch 1 taken 2150 times.
2973 if(info.isUnwalkable())
14965 {
14966
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 776 times.
823 if(y != y.getInt())
14967 {
14968 47 y.doRound();
14969 47 }
14970
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 388 times.
776 else if(hero_newstep_diag > 1)
14971 {
14972
1/2
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
388 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14973 388 hero_newstep_diag.doFloor();
14974 else --hero_newstep_diag;
14975 388 }
14976 else
14977 388 shiftdir = -1;
14978 823 }
14979
2/2
✓ Branch 0 taken 1768 times.
✓ Branch 1 taken 382 times.
2150 else if(walkable)
14980 {
14981 1768 do
14982 {
14983 1771 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
14984 1771 execute(info);
14985
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1766 times.
1771 if(info.isUnwalkable())
14986 {
14987
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if(y != y.getInt())
14988 {
14989 1 y.doRound();
14990 1 }
14991
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
14992 {
14993
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14994 2 hero_newstep_diag.doFloor();
14995 else --hero_newstep_diag;
14996 2 }
14997 else
14998 2 shiftdir = -1;
14999 5 }
15000 1766 else break;
15001
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 }
15002 5 while(shiftdir != -1);
15003 1768 break;
15004 }
15005 382 else break;
15006
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 388 times.
823 }
15007 823 while(shiftdir != -1);
15008 2538 }
15009 }
15010
15011 22786 moveOld2(left);
15012 22786 shiftdir=s;
15013
15014
2/2
✓ Branch 0 taken 20381 times.
✓ Branch 1 taken 2405 times.
22786 if(!walkable)
15015 {
15016
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 1434 times.
2405 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15017 {
15018 1434 x = x.getInt();
15019 1434 y = y.getInt();
15020 1434 int32_t v1=bigHitbox?0:8;
15021 1434 int32_t v2=bigHitbox?8:12;
15022
15023
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1434 times.
✓ Branch 2 taken 1434 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1261 times.
✓ Branch 5 taken 173 times.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 1403 times.
1607 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15024
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 173 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
✓ Branch 4 taken 142 times.
✓ Branch 5 taken 31 times.
173 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15025
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
31 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15026 {
15027
4/8
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31 times.
31 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15028 31 sprite::move((zfix)0,(zfix)-1);
15029 31 }
15030
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1403 times.
✓ Branch 4 taken 142 times.
✓ Branch 5 taken 1261 times.
✓ Branch 6 taken 35 times.
✓ Branch 7 taken 1368 times.
2664 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15031
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1261 times.
✓ Branch 4 taken 1226 times.
✓ Branch 5 taken 35 times.
1261 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15032
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15033 {
15034
4/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 35 times.
35 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15035 35 sprite::move((zfix)0,(zfix)1);
15036 35 }
15037 else
15038 {
15039 1368 pushing=push+1;
15040 }
15041 1434 }
15042 else
15043 {
15044 971 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15045
15046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 971 times.
971 if(action!=swimming)
15047 {
15048 971 }
15049 }
15050 2405 }
15051
15052 22786 return;
15053 }
15054 }
15055
15056
5/6
✓ Branch 0 taken 24416 times.
✓ Branch 1 taken 45845 times.
✓ Branch 2 taken 23581 times.
✓ Branch 3 taken 835 times.
✓ Branch 4 taken 23581 times.
✗ Branch 5 not taken.
70261 if(DrunkRight()&&(holddir==-1||holddir==right))
15057 {
15058
4/8
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 24258 times.
✓ Branch 2 taken 158 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 158 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
24416 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15059 {
15060 }
15061 else
15062 {
15063
3/6
✓ Branch 0 taken 24416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24416 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24416 times.
24416 if(charging==0 && spins==0 && action != sideswimattacking)
15064 {
15065 24416 dir=right;
15066 24416 }
15067 24416 sideswimdir = right;
15068
15069 24416 holddir=right;
15070
15071
3/4
✓ Branch 0 taken 2783 times.
✓ Branch 1 taken 21633 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2783 times.
24416 if(DrunkUp()&&shiftdir!=down)
15072 {
15073 2783 shiftdir=up;
15074 2783 }
15075
4/4
✓ Branch 0 taken 2786 times.
✓ Branch 1 taken 18847 times.
✓ Branch 2 taken 2784 times.
✓ Branch 3 taken 2 times.
21633 else if(DrunkDown()&&shiftdir!=up)
15076 {
15077 2784 shiftdir=down;
15078 2784 }
15079 else
15080 {
15081 18849 shiftdir=-1;
15082 }
15083
15084 24416 do
15085 {
15086 27056 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
15087
15088 27056 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
15089
15090 27056 execute(info);
15091
15092
2/2
✓ Branch 0 taken 5058 times.
✓ Branch 1 taken 21998 times.
27056 if(info.isUnwalkable())
15093 {
15094
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 4846 times.
5058 if(x != x.getInt())
15095 {
15096 212 x.doRound();
15097 212 }
15098
2/2
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 2418 times.
4846 else if(hero_newstep > 1)
15099 {
15100
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(hero_newstep != int32_t(hero_newstep)) //floor
15101 2428 hero_newstep = floor((double)hero_newstep);
15102 else --hero_newstep;
15103 2428 }
15104 else
15105 2418 break;
15106 2640 }
15107 21998 else walkable = true;
15108
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 21998 times.
24638 }
15109 24638 while(!walkable);
15110
15111 24416 int32_t s=shiftdir;
15112
15113
6/14
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 24258 times.
✓ Branch 2 taken 151 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 158 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 24416 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
24416 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15114 {
15115 shiftdir=-1;
15116 }
15117 else
15118 {
15119
2/2
✓ Branch 0 taken 21633 times.
✓ Branch 1 taken 2783 times.
24416 if(s==up)
15120 {
15121 2783 do
15122 {
15123 3067 zfix ty = y - hero_newstep_diag;
15124 6134 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15125 3067 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15126
15127
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3067 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3067 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15128 {
15129 info = info || walkflag(x, zfix(0), 2, up);
15130 info = info || walkflag(x+15, zfix(0), 1, up);
15131 }
15132 3067 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15133
15134 3067 execute(info);
15135
15136
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 2540 times.
3067 if(info.isUnwalkable())
15137 {
15138
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 486 times.
527 if(y != y.getInt())
15139 {
15140 41 y.doRound();
15141 41 }
15142
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 243 times.
486 else if(hero_newstep_diag > 1)
15143 {
15144
1/2
✓ Branch 0 taken 243 times.
✗ Branch 1 not taken.
243 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15145 243 hero_newstep_diag.doFloor();
15146 else --hero_newstep_diag;
15147 243 }
15148 else
15149 243 shiftdir = -1;
15150 527 }
15151
2/2
✓ Branch 0 taken 2205 times.
✓ Branch 1 taken 335 times.
2540 else if(walkable)
15152 {
15153 2205 do
15154 {
15155 2224 zfix tx = x+hero_newstep, ty = y-hero_newstep_diag;
15156 2224 info = walkflag(tx+15,(bigHitbox?0:8)+ty,1,up);
15157
15158
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2224 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2224 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15159 {
15160 info = info || walkflag(tx, zfix(0), 1, up);
15161 info = info || walkflag(tx+15, zfix(0), 1, up);
15162 }
15163 2224 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
15164 2224 execute(info);
15165
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2194 times.
2224 if(info.isUnwalkable())
15166 {
15167
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 22 times.
30 if(y != y.getInt())
15168 {
15169 8 y.doRound();
15170 8 }
15171
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(hero_newstep_diag > 1)
15172 {
15173
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15174 11 hero_newstep_diag.doFloor();
15175 else --hero_newstep_diag;
15176 11 }
15177 else
15178 11 shiftdir = -1;
15179 30 }
15180 2194 else break;
15181
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 11 times.
30 }
15182 30 while(shiftdir != -1);
15183 2205 break;
15184 }
15185 335 else break;
15186
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 243 times.
527 }
15187 527 while(shiftdir != -1);
15188 2783 }
15189
2/2
✓ Branch 0 taken 18849 times.
✓ Branch 1 taken 2784 times.
21633 else if(s==down)
15190 {
15191 2784 do
15192 {
15193 3281 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
15194
15195 3281 execute(info);
15196
15197
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 2348 times.
3281 if(info.isUnwalkable())
15198 {
15199
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 872 times.
933 if(y != y.getInt())
15200 {
15201 61 y.doRound();
15202 61 }
15203
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 436 times.
872 else if(hero_newstep_diag > 1)
15204 {
15205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15206 436 hero_newstep_diag.doFloor();
15207 else --hero_newstep_diag;
15208 436 }
15209 else
15210 436 shiftdir = -1;
15211 933 }
15212
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 360 times.
2348 else if(walkable)
15213 {
15214 1988 do
15215 {
15216 2000 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
15217 2000 execute(info);
15218
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1981 times.
2000 if(info.isUnwalkable())
15219 {
15220
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15 times.
19 if(y != y.getInt())
15221 {
15222 4 y.doRound();
15223 4 }
15224
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 7 times.
15 else if(hero_newstep_diag > 1)
15225 {
15226
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15227 8 hero_newstep_diag.doFloor();
15228 else --hero_newstep_diag;
15229 8 }
15230 else
15231 7 shiftdir = -1;
15232 19 }
15233 1981 else break;
15234
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 }
15235 19 while(shiftdir != -1);
15236 1988 break;
15237 }
15238 360 else break;
15239
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 436 times.
933 }
15240 933 while(shiftdir != -1);
15241 2784 }
15242 }
15243
15244 24416 moveOld2(right);
15245 24416 shiftdir=s;
15246
15247
2/2
✓ Branch 0 taken 21998 times.
✓ Branch 1 taken 2418 times.
24416 if(!walkable)
15248 {
15249
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 1668 times.
2418 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15250 {
15251 1668 x = x.getInt();
15252 1668 y = y.getInt();
15253 1668 int32_t v1=bigHitbox?0:8;
15254 1668 int32_t v2=bigHitbox?8:12;
15255
15256
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1668 times.
✓ Branch 2 taken 1668 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1532 times.
✓ Branch 5 taken 136 times.
✓ Branch 6 taken 47 times.
✓ Branch 7 taken 1621 times.
1804 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
15257
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 47 times.
136 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
15258
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
15259 {
15260
4/8
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 47 times.
47 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15261 47 sprite::move((zfix)0,(zfix)-1);
15262 47 }
15263
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1621 times.
✓ Branch 2 taken 1621 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 1532 times.
✓ Branch 6 taken 56 times.
✓ Branch 7 taken 1565 times.
3153 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
15264
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1532 times.
✓ Branch 4 taken 1476 times.
✓ Branch 5 taken 56 times.
1532 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
15265
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 56 times.
56 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
15266 {
15267
4/8
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 56 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 56 times.
56 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15268 56 sprite::move((zfix)0,(zfix)1);
15269 56 }
15270 else
15271 {
15272 1565 pushing=push+1;
15273 1565 z3step=2;
15274 }
15275 1668 }
15276 else
15277 {
15278 750 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15279
15280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750 times.
750 if(action!=swimming)
15281 {
15282 750 }
15283 }
15284 2418 }
15285
15286 24416 return;
15287 }
15288 }
15289 45845 }
15290 else
15291 {
15292
6/6
✓ Branch 0 taken 55400 times.
✓ Branch 1 taken 458420 times.
✓ Branch 2 taken 54153 times.
✓ Branch 3 taken 1247 times.
✓ Branch 4 taken 12476 times.
✓ Branch 5 taken 41677 times.
513820 if(DrunkUp()&&(holddir==-1||holddir==up))
15293 {
15294
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42924 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42924 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15295 {
15296 }
15297 else
15298 {
15299
2/4
✓ Branch 0 taken 42924 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42924 times.
42924 if(charging==0 && spins==0)
15300 {
15301 42924 dir=up;
15302 42924 }
15303
15304 42924 holddir=up;
15305
15306
4/4
✓ Branch 0 taken 5386 times.
✓ Branch 1 taken 37538 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 5379 times.
42924 if(DrunkRight()&&shiftdir!=left)
15307 {
15308 5379 shiftdir=right;
15309 5379 }
15310
4/4
✓ Branch 0 taken 4022 times.
✓ Branch 1 taken 33523 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 4016 times.
37545 else if(DrunkLeft()&&shiftdir!=right)
15311 {
15312 4016 shiftdir=left;
15313 4016 }
15314 else
15315 {
15316 33529 shiftdir=-1;
15317 }
15318
15319 //walkable if Ladder can be placed or is already placed vertically
15320
10/18
✓ Branch 0 taken 16485 times.
✓ Branch 1 taken 26439 times.
✓ Branch 2 taken 16485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16354 times.
✓ Branch 5 taken 131 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16354 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 16354 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 16354 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16354 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16354 times.
42924 if(isSideViewHero() && !toogam && !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15321 {
15322 16354 walkable=false;
15323 16354 }
15324 else
15325 {
15326 26570 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15327
15328
2/2
✓ Branch 0 taken 12096 times.
✓ Branch 1 taken 14474 times.
26570 if(x.getInt() & 7)
15329 12096 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15330 else
15331 14474 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15332
15333 26570 execute(info);
15334
15335
2/2
✓ Branch 0 taken 3191 times.
✓ Branch 1 taken 23379 times.
26570 if(info.isUnwalkable())
15336 {
15337
2/2
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 84 times.
3191 if(z3step==2)
15338 {
15339 3107 z3step=1;
15340 3107 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15341
15342
2/2
✓ Branch 0 taken 1821 times.
✓ Branch 1 taken 1286 times.
3107 if(x.getInt()&7)
15343 1286 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15344 else
15345 1821 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15346
15347 3107 execute(info);
15348
15349
2/2
✓ Branch 0 taken 2980 times.
✓ Branch 1 taken 127 times.
3107 if(info.isUnwalkable())
15350 {
15351 2980 walkable = false;
15352 2980 }
15353 else
15354 {
15355 127 walkable=true;
15356 }
15357 3107 }
15358 else
15359 {
15360 84 walkable=false;
15361 }
15362 3191 }
15363 else
15364 {
15365 23379 walkable = true;
15366 }
15367 }
15368
15369 42924 int32_t s=shiftdir;
15370
15371
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 42924 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
42924 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15372 {
15373 shiftdir=-1;
15374 }
15375 else
15376 {
15377
2/2
✓ Branch 0 taken 4016 times.
✓ Branch 1 taken 38908 times.
42924 if(s==left)
15378 {
15379 4016 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
15380 4016 execute(info);
15381
15382
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 3505 times.
4016 if(info.isUnwalkable())
15383 {
15384 511 shiftdir=-1;
15385 511 }
15386
2/2
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 2241 times.
3505 else if(walkable)
15387 {
15388 2241 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
15389 2241 execute(info);
15390
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 3 times.
2241 if(info.isUnwalkable())
15391 {
15392 3 shiftdir=-1;
15393 3 }
15394 2241 }
15395 4016 }
15396
2/2
✓ Branch 0 taken 33529 times.
✓ Branch 1 taken 5379 times.
38908 else if(s==right)
15397 {
15398 5379 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15399 5379 execute(info);
15400
15401
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 4599 times.
5379 if(info.isUnwalkable())
15402 {
15403 780 shiftdir=-1;
15404 780 }
15405
2/2
✓ Branch 0 taken 1732 times.
✓ Branch 1 taken 2867 times.
4599 else if(walkable)
15406 {
15407 2867 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
15408 2867 execute(info);
15409
15410
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 2 times.
2867 if(info.isUnwalkable())
15411 {
15412 2 shiftdir=-1;
15413 2 }
15414 2867 }
15415 5379 }
15416 }
15417
15418 42924 moveOld2(up);
15419 42924 shiftdir=s;
15420
15421
2/2
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 19418 times.
42924 if(!walkable)
15422 {
15423
2/2
✓ Branch 0 taken 3598 times.
✓ Branch 1 taken 15820 times.
19418 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15424 {
15425
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15820 times.
✓ Branch 2 taken 15820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2054 times.
✓ Branch 5 taken 13766 times.
✓ Branch 6 taken 159 times.
✓ Branch 7 taken 15661 times.
29586 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15426
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13766 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13766 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 13598 times.
13766 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15427
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13598 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13598 times.
13598 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15428 {
15429
5/8
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 159 times.
159 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15430 159 sprite::move((zfix)-1,(zfix)0);
15431 159 }
15432 else
15433 {
15434
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15661 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15661 times.
✓ Branch 4 taken 13607 times.
✓ Branch 5 taken 2054 times.
✓ Branch 6 taken 122 times.
✓ Branch 7 taken 15539 times.
17715 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15435
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054 times.
✓ Branch 4 taken 1932 times.
✓ Branch 5 taken 122 times.
2054 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15436
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
122 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15437 {
15438
5/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 122 times.
122 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15439 122 sprite::move((zfix)1,(zfix)0);
15440 122 }
15441 else
15442 {
15443 15539 pushing=push+1;
15444 }
15445 }
15446
15447 15820 z3step=2;
15448 15820 }
15449 else
15450 {
15451 3598 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15452 3598 z3step=2;
15453 }
15454 19418 }
15455
15456 42924 return;
15457 }
15458 }
15459
15460
6/6
✓ Branch 0 taken 37469 times.
✓ Branch 1 taken 433427 times.
✓ Branch 2 taken 36480 times.
✓ Branch 3 taken 989 times.
✓ Branch 4 taken 27508 times.
✓ Branch 5 taken 8972 times.
470896 if(DrunkDown()&&(holddir==-1||holddir==down))
15461 {
15462
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 28497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28497 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15463 {
15464 }
15465 else
15466 {
15467
2/4
✓ Branch 0 taken 28497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28497 times.
✗ Branch 3 not taken.
28497 if(charging==0 && spins==0)
15468 {
15469 28497 dir=down;
15470 28497 }
15471
15472 28497 holddir=down;
15473
15474
4/4
✓ Branch 0 taken 4174 times.
✓ Branch 1 taken 24323 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4170 times.
28497 if(DrunkRight()&&shiftdir!=left)
15475 {
15476 4170 shiftdir=right;
15477 4170 }
15478
4/4
✓ Branch 0 taken 3439 times.
✓ Branch 1 taken 20888 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3436 times.
24327 else if(DrunkLeft()&&shiftdir!=right)
15479 {
15480 3436 shiftdir=left;
15481 3436 }
15482 else
15483 {
15484 20891 shiftdir=-1;
15485 }
15486
15487 //bool walkable;
15488
7/12
✓ Branch 0 taken 9145 times.
✓ Branch 1 taken 19352 times.
✓ Branch 2 taken 9145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9145 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9145 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 9145 times.
28497 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15489 {
15490 9145 walkable=false;
15491 9145 }
15492 else
15493 {
15494 19352 info = walkflag(x,y+15+z3step,2,down);
15495
15496
2/2
✓ Branch 0 taken 9248 times.
✓ Branch 1 taken 10104 times.
19352 if(x.getInt()&7)
15497 9248 info = info || walkflag(x+16,y+15+z3step,1,down);
15498 else
15499 10104 info = info || walkflagMBlock(x+16, y+15+z3step);
15500
15501 19352 execute(info);
15502
15503
2/2
✓ Branch 0 taken 2393 times.
✓ Branch 1 taken 16959 times.
19352 if(info.isUnwalkable())
15504 {
15505
2/2
✓ Branch 0 taken 2327 times.
✓ Branch 1 taken 66 times.
2393 if(z3step==2)
15506 {
15507 2327 z3step=1;
15508 2327 info = walkflag(x,y+15+z3step,2,down);
15509
15510
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 1301 times.
2327 if(x.getInt()&7)
15511 1026 info = info || walkflag(x+16,y+15+z3step,1,down);
15512 else
15513 1301 info = info || walkflagMBlock(x+16, y+15+z3step);
15514
15515 2327 execute(info);
15516
15517
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 79 times.
2327 if(info.isUnwalkable())
15518 {
15519 2248 walkable = false;
15520 2248 }
15521 else
15522 {
15523 79 walkable=true;
15524 }
15525 2327 }
15526 else
15527 {
15528 66 walkable=false;
15529 }
15530 2393 }
15531 else
15532 {
15533 16959 walkable = true;
15534 }
15535 }
15536
15537 28497 int32_t s=shiftdir;
15538
15539
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28497 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15540 {
15541 shiftdir=-1;
15542 }
15543 else
15544 {
15545
2/2
✓ Branch 0 taken 3436 times.
✓ Branch 1 taken 25061 times.
28497 if(s==left)
15546 {
15547 3436 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
15548 3436 execute(info);
15549
15550
2/2
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 3043 times.
3436 if(info.isUnwalkable())
15551 {
15552 393 shiftdir=-1;
15553 393 }
15554
2/2
✓ Branch 0 taken 1343 times.
✓ Branch 1 taken 1700 times.
3043 else if(walkable)
15555 {
15556 1700 info = walkflag(x-1,y+16,1,left);
15557 1700 execute(info);
15558
15559
2/2
✓ Branch 0 taken 1696 times.
✓ Branch 1 taken 4 times.
1700 if(info.isUnwalkable())
15560 {
15561 4 shiftdir=-1;
15562 4 }
15563 1700 }
15564 3436 }
15565
2/2
✓ Branch 0 taken 20891 times.
✓ Branch 1 taken 4170 times.
25061 else if(s==right)
15566 {
15567 4170 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15568 4170 execute(info);
15569
15570
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 3609 times.
4170 if(info.isUnwalkable())
15571 {
15572 561 shiftdir=-1;
15573 561 }
15574
2/2
✓ Branch 0 taken 1112 times.
✓ Branch 1 taken 2497 times.
3609 else if(walkable)
15575 {
15576 2497 info = walkflag(x+16,y+16,1,right);
15577 2497 execute(info);
15578
15579
2/2
✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 9 times.
2497 if(info.isUnwalkable())
15580 {
15581 9 shiftdir=-1;
15582 9 }
15583 2497 }
15584 4170 }
15585 }
15586
15587 28497 moveOld2(down);
15588 28497 shiftdir=s;
15589
15590
2/2
✓ Branch 0 taken 17038 times.
✓ Branch 1 taken 11459 times.
28497 if(!walkable)
15591 {
15592
2/2
✓ Branch 0 taken 2736 times.
✓ Branch 1 taken 8723 times.
11459 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15593 {
15594
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8723 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8723 times.
✓ Branch 4 taken 3004 times.
✓ Branch 5 taken 5719 times.
✓ Branch 6 taken 115 times.
✓ Branch 7 taken 8608 times.
14442 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15595
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5719 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5719 times.
✓ Branch 4 taken 172 times.
✓ Branch 5 taken 5547 times.
5719 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15596
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5547 times.
5547 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15597 {
15598
4/8
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 115 times.
115 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15599 115 sprite::move((zfix)-1,(zfix)0);
15600 115 }
15601
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8608 times.
✓ Branch 4 taken 5604 times.
✓ Branch 5 taken 3004 times.
✓ Branch 6 taken 123 times.
✓ Branch 7 taken 8485 times.
11612 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15602
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3004 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3004 times.
✓ Branch 4 taken 2881 times.
✓ Branch 5 taken 123 times.
3004 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15603
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
123 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15604 {
15605
5/8
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 123 times.
123 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15606 123 sprite::move((zfix)1,(zfix)0);
15607 123 }
15608 else //if(shiftdir==-1)
15609 {
15610 8485 pushing=push+1;
15611
15612
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 8444 times.
8485 if(action!=swimming)
15613 {
15614 8444 }
15615 }
15616
15617 8723 z3step=2;
15618 8723 }
15619 else
15620 {
15621 2736 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15622
15623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2736 times.
2736 if(action!=swimming)
15624 {
15625 2736 }
15626
15627 2736 z3step=2;
15628 }
15629 11459 }
15630
15631 28497 return;
15632 }
15633 }
15634
15635
6/6
✓ Branch 0 taken 111365 times.
✓ Branch 1 taken 331034 times.
✓ Branch 2 taken 108136 times.
✓ Branch 3 taken 3229 times.
✓ Branch 4 taken 108035 times.
✓ Branch 5 taken 101 times.
442399 if(DrunkLeft()&&(holddir==-1||holddir==left))
15636 {
15637
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 111264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
111264 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15638 {
15639 }
15640 else
15641 {
15642
2/4
✓ Branch 0 taken 111264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 111264 times.
111264 if(charging==0 && spins==0)
15643 {
15644 111264 dir=left;
15645 111264 }
15646
15647 111264 holddir=left;
15648
15649
4/4
✓ Branch 0 taken 5464 times.
✓ Branch 1 taken 105800 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 5463 times.
111264 if(DrunkUp()&&shiftdir!=down)
15650 {
15651 5463 shiftdir=up;
15652 5463 }
15653
3/4
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 101747 times.
✓ Branch 2 taken 4054 times.
✗ Branch 3 not taken.
105801 else if(DrunkDown()&&shiftdir!=up)
15654 {
15655 4054 shiftdir=down;
15656 4054 }
15657 else
15658 {
15659 101747 shiftdir=-1;
15660 }
15661
15662 //bool walkable;
15663 111264 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15664
15665
2/2
✓ Branch 0 taken 70635 times.
✓ Branch 1 taken 40629 times.
111264 if(y.getInt()&7)
15666 40629 info = info || walkflag(x-z3step,y+16,1,left);
15667
15668 111264 execute(info);
15669
15670
2/2
✓ Branch 0 taken 13124 times.
✓ Branch 1 taken 98140 times.
111264 if(info.isUnwalkable())
15671 {
15672
2/2
✓ Branch 0 taken 12864 times.
✓ Branch 1 taken 260 times.
13124 if(z3step==2)
15673 {
15674 12864 z3step=1;
15675 12864 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15676
15677
2/2
✓ Branch 0 taken 4993 times.
✓ Branch 1 taken 7871 times.
12864 if(y.getInt()&7)
15678 4993 info = info || walkflag(x-z3step,y+16,1,left);
15679
15680 12864 execute(info);
15681
15682
2/2
✓ Branch 0 taken 12595 times.
✓ Branch 1 taken 269 times.
12864 if(info.isUnwalkable())
15683 {
15684 12595 walkable = false;
15685 12595 }
15686 else
15687 {
15688 269 walkable=true;
15689 }
15690 12864 }
15691 else
15692 {
15693 260 walkable=false;
15694 }
15695 13124 }
15696 else
15697 {
15698 98140 walkable = true;
15699 }
15700
15701 111264 int32_t s=shiftdir;
15702
15703
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 111264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56334 times.
✓ Branch 7 taken 54930 times.
✓ Branch 8 taken 56334 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56334 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 56334 times.
✗ Branch 13 not taken.
111264 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15704 {
15705 56334 shiftdir=-1;
15706 56334 }
15707 else
15708 {
15709
2/2
✓ Branch 0 taken 50758 times.
✓ Branch 1 taken 4172 times.
54930 if(s==up)
15710 {
15711 4172 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15712 4172 execute(info);
15713
15714
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 3772 times.
4172 if(info.isUnwalkable())
15715 {
15716 400 shiftdir=-1;
15717 400 }
15718
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 3462 times.
3772 else if(walkable)
15719 {
15720 3462 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
15721 3462 execute(info);
15722
15723
2/2
✓ Branch 0 taken 3458 times.
✓ Branch 1 taken 4 times.
3462 if(info.isUnwalkable())
15724 {
15725 4 shiftdir=-1;
15726 4 }
15727 3462 }
15728 4172 }
15729
2/2
✓ Branch 0 taken 47265 times.
✓ Branch 1 taken 3493 times.
50758 else if(s==down)
15730 {
15731 3493 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15732 3493 execute(info);
15733
15734
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 3107 times.
3493 if(info.isUnwalkable())
15735 {
15736 386 shiftdir=-1;
15737 386 }
15738
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2826 times.
3107 else if(walkable)
15739 {
15740 2826 info = walkflag(x-1,y+16,1,down);
15741 2826 execute(info);
15742
15743
2/2
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 3 times.
2826 if(info.isUnwalkable())
15744 {
15745 3 shiftdir=-1;
15746 3 }
15747 2826 }
15748 3493 }
15749 }
15750
15751 111264 moveOld2(left);
15752 111264 shiftdir=s;
15753
15754
2/2
✓ Branch 0 taken 98409 times.
✓ Branch 1 taken 12855 times.
111264 if(!walkable)
15755 {
15756
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 11923 times.
12855 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15757 {
15758 11923 int32_t v1=bigHitbox?0:8;
15759 11923 int32_t v2=bigHitbox?8:12;
15760
15761
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11923 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11923 times.
✓ Branch 4 taken 10609 times.
✓ Branch 5 taken 1314 times.
✓ Branch 6 taken 621 times.
✓ Branch 7 taken 11302 times.
13237 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15762
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1314 times.
✓ Branch 2 taken 1314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 621 times.
1314 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15763
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 621 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 621 times.
621 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15764 {
15765
5/8
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 540 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 540 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 621 times.
621 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15766 621 sprite::move((zfix)0,(zfix)-1);
15767 621 }
15768
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11302 times.
✓ Branch 2 taken 11302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 10609 times.
✓ Branch 6 taken 224 times.
✓ Branch 7 taken 11078 times.
21911 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15769
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10609 times.
✓ Branch 4 taken 10385 times.
✓ Branch 5 taken 224 times.
10609 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15770
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 224 times.
224 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15771 {
15772
6/8
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 181 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 223 times.
224 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15773 223 sprite::move((zfix)0,(zfix)1);
15774 224 }
15775 else //if(shiftdir==-1)
15776 {
15777 11078 pushing=push+1;
15778
15779
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 11030 times.
11078 if(action!=swimming)
15780 {
15781 11030 }
15782 }
15783
15784 11923 z3step=2;
15785 11923 }
15786 else
15787 {
15788 932 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15789
15790
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 923 times.
932 if(action!=swimming)
15791 {
15792 923 }
15793
15794 932 z3step=2;
15795 }
15796 12855 }
15797
15798 111264 return;
15799 }
15800 }
15801
15802
5/6
✓ Branch 0 taken 134155 times.
✓ Branch 1 taken 196980 times.
✓ Branch 2 taken 130485 times.
✓ Branch 3 taken 3670 times.
✓ Branch 4 taken 130485 times.
✗ Branch 5 not taken.
331135 if(DrunkRight()&&(holddir==-1||holddir==right))
15803 {
15804
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 134155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
134155 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15805 {
15806 }
15807 else
15808 {
15809
2/4
✓ Branch 0 taken 134155 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 134155 times.
134155 if(charging==0 && spins==0)
15810 {
15811 134155 dir=right;
15812 134155 }
15813
15814 134155 holddir=right;
15815
15816
4/4
✓ Branch 0 taken 6952 times.
✓ Branch 1 taken 127203 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 6951 times.
134155 if(DrunkUp()&&shiftdir!=down)
15817 {
15818 6951 shiftdir=up;
15819 6951 }
15820
3/4
✓ Branch 0 taken 4918 times.
✓ Branch 1 taken 122286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4918 times.
127204 else if(DrunkDown()&&shiftdir!=up)
15821 {
15822 4918 shiftdir=down;
15823 4918 }
15824 else
15825 {
15826 122286 shiftdir=-1;
15827 }
15828
15829 //bool walkable;
15830 134155 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15831
15832
2/2
✓ Branch 0 taken 85264 times.
✓ Branch 1 taken 48891 times.
134155 if(y.getInt()&7)
15833 48891 info = info || walkflag(x+15+z3step,y+16,1,right);
15834
15835 134155 execute(info);
15836
15837
2/2
✓ Branch 0 taken 14498 times.
✓ Branch 1 taken 119657 times.
134155 if(info.isUnwalkable())
15838 {
15839
2/2
✓ Branch 0 taken 14220 times.
✓ Branch 1 taken 278 times.
14498 if(z3step==2)
15840 {
15841 14220 z3step=1;
15842 14220 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15843
15844
2/2
✓ Branch 0 taken 6842 times.
✓ Branch 1 taken 7378 times.
14220 if(y.getInt()&7)
15845 6842 info = info || walkflag(x+15+z3step,y+16,1,right);
15846
15847 14220 execute(info);
15848
15849
2/2
✓ Branch 0 taken 13818 times.
✓ Branch 1 taken 402 times.
14220 if(info.isUnwalkable())
15850 {
15851 13818 walkable = false;
15852 13818 }
15853 else
15854 {
15855 402 walkable=true;
15856 }
15857 14220 }
15858 else
15859 {
15860 278 walkable=false;
15861 }
15862 14498 }
15863 else
15864 {
15865 119657 walkable = true;
15866 }
15867
15868 134155 int32_t s=shiftdir;
15869
15870
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 134155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 65926 times.
✓ Branch 7 taken 68229 times.
✓ Branch 8 taken 65926 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 65926 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 65926 times.
✗ Branch 13 not taken.
134155 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15871 {
15872 65926 shiftdir=-1;
15873 65926 }
15874 else
15875 {
15876
2/2
✓ Branch 0 taken 63040 times.
✓ Branch 1 taken 5189 times.
68229 if(s==up)
15877 {
15878 5189 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15879 5189 execute(info);
15880
15881
2/2
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 4810 times.
5189 if(info.isUnwalkable())
15882 {
15883 379 shiftdir=-1;
15884 379 }
15885
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 4416 times.
4810 else if(walkable)
15886 {
15887 4416 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
15888 4416 execute(info);
15889
15890
2/2
✓ Branch 0 taken 4409 times.
✓ Branch 1 taken 7 times.
4416 if(info.isUnwalkable())
15891 {
15892 7 shiftdir=-1;
15893 7 }
15894 4416 }
15895 5189 }
15896
2/2
✓ Branch 0 taken 58599 times.
✓ Branch 1 taken 4441 times.
63040 else if(s==down)
15897 {
15898 4441 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15899 4441 execute(info);
15900
15901
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 3827 times.
4441 if(info.isUnwalkable())
15902 {
15903 614 shiftdir=-1;
15904 614 }
15905
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 3377 times.
3827 else if(walkable)
15906 {
15907 3377 info = walkflag(x+16,y+16,1,down);
15908 3377 execute(info);
15909
15910
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 14 times.
3377 if(info.isUnwalkable())
15911 {
15912 14 shiftdir=-1;
15913 14 }
15914 3377 }
15915 4441 }
15916 }
15917
15918 134155 moveOld2(right);
15919 134155 shiftdir=s;
15920
15921
2/2
✓ Branch 0 taken 120059 times.
✓ Branch 1 taken 14096 times.
134155 if(!walkable)
15922 {
15923
2/2
✓ Branch 0 taken 1415 times.
✓ Branch 1 taken 12681 times.
14096 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15924 {
15925 12681 int32_t v1=bigHitbox?0:8;
15926 12681 int32_t v2=bigHitbox?8:12;
15927
15928 38043 info = !walkflag(x+16,y+v1,1,right)&&
15929 25362 !walkflag(x+16,y+v2,1,right)&&
15930 12681 walkflag(x+16,y+15,1,right);
15931
15932 //do NOT execute these
15933
2/2
✓ Branch 0 taken 930 times.
✓ Branch 1 taken 11751 times.
12681 if(info.isUnwalkable())
15934 {
15935
6/8
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 905 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 905 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 929 times.
930 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15936 929 sprite::move((zfix)0,(zfix)-1);
15937 930 }
15938 else
15939 {
15940 35253 info = walkflag(x+16,y+v1, 1,right)&&
15941 23502 !walkflag(x+16,y+v2-1,1,right)&&
15942 11751 !walkflag(x+16,y+15, 1,right);
15943
15944
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 11437 times.
11751 if(info.isUnwalkable())
15945 {
15946
5/8
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 299 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 314 times.
314 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15947 314 sprite::move((zfix)0,(zfix)1);
15948 314 }
15949 else //if(shiftdir==-1)
15950 {
15951 11437 pushing=push+1;
15952 11437 z3step=2;
15953
15954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11437 times.
11437 if(action!=swimming)
15955 {
15956 11437 }
15957 }
15958 }
15959
15960 12681 z3step=2;
15961 12681 }
15962 else
15963 {
15964 1415 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15965
15966
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1409 times.
1415 if(action!=swimming)
15967 {
15968 1409 }
15969
15970 1415 z3step=2;
15971 }
15972 14096 }
15973
15974 134155 return;
15975 }
15976 }
15977 }
15978
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 242825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
242825 if(shield_forcedir > -1 && action != rafting)
15979 dir = shield_forcedir;
15980 242825 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
15981 242825 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
15982 242825 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
15983 242825 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
15984 242825 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
15985
15986
8/12
✓ Branch 0 taken 70324 times.
✓ Branch 1 taken 172501 times.
✓ Branch 2 taken 70324 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 70324 times.
✓ Branch 6 taken 70324 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 67541 times.
✓ Branch 9 taken 2783 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 67541 times.
242825 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
15987 {
15988
8/12
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 67340 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 152 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 152 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
67541 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
15989 {
15990 //action=swimming;
15991
3/12
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
152 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
15992 {
15993 hopclk = 0xFF;
15994 }
15995 152 }
15996 67541 }
15997
15998 242825 return;
15999 } //endif (LTTPWALK)
16000 2329599 temp_step = hero_newstep;
16001 2329599 temp_x = x;
16002 2329599 temp_y = y;
16003
16004
7/8
✓ Branch 0 taken 1488191 times.
✓ Branch 1 taken 841408 times.
✓ Branch 2 taken 1456800 times.
✓ Branch 3 taken 31391 times.
✓ Branch 4 taken 43770 times.
✓ Branch 5 taken 1444421 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 43770 times.
2329599 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16005 {
16006
2/4
✓ Branch 0 taken 43770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43770 times.
43770 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16007 goto LEFTRIGHT_NEWMOVE;
16008 43770 else goto LEFTRIGHT_OLDMOVE;
16009 }
16010
16011 // make it easier to get in left & right doors
16012
16013 //ignore ladder for this part. sigh sigh sigh -DD
16014 2285829 oldladderx = ladderx;
16015 2285829 oldladdery = laddery;
16016
2/4
✓ Branch 0 taken 2285829 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2285829 times.
2285829 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16017 {
16018 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
16019 {
16020 do
16021 {
16022 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
16023 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
16024
16025 if(info.isUnwalkable())
16026 {
16027 if(temp_x != int32_t(temp_x))
16028 {
16029 temp_x = floor((double)temp_x);
16030 }
16031 else if(temp_step > 1)
16032 {
16033 if(temp_step != int32_t(temp_step)) //floor
16034 temp_step = floor((double)temp_step);
16035 else --temp_step;
16036 }
16037 else
16038 break;
16039 }
16040 }
16041 while(info.isUnwalkable());
16042
16043 if(!info.isUnwalkable())
16044 {
16045 x = temp_x;
16046 y = temp_y;
16047 hero_newstep = temp_step;
16048 //ONLY process the side-effects of the above walkflag if Hero will actually move
16049 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16050 execute(info);
16051 moveOld2(left);
16052 return;
16053 }
16054 temp_x = x;
16055 temp_y = y;
16056 temp_step = hero_newstep;
16057 }
16058
16059 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
16060 {
16061 do
16062 {
16063 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16064 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
16065
16066 if(info.isUnwalkable())
16067 {
16068 if(temp_x != int32_t(temp_x))
16069 {
16070 temp_x = floor((double)temp_x);
16071 }
16072 else if(temp_step > 1)
16073 {
16074 if(temp_step != int32_t(temp_step)) //floor
16075 temp_step = floor((double)temp_step);
16076 else --temp_step;
16077 }
16078 else
16079 break;
16080 }
16081 }
16082 while(info.isUnwalkable());
16083
16084 if(!info.isUnwalkable())
16085 {
16086 x = temp_x;
16087 y = temp_y;
16088 hero_newstep = temp_step;
16089 execute(info);
16090 moveOld2(right);
16091 return;
16092 }
16093 temp_x = x;
16094 temp_y = y;
16095 temp_step = hero_newstep;
16096 }
16097
16098 ladderx = oldladderx;
16099 laddery = oldladdery;
16100
16101 if(DrunkUp())
16102 {
16103 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16104 {
16105 if(dir!=up && dir!=down)
16106 {
16107 if(xoff>2&&xoff<6)
16108 {
16109 moveOld2(dir);
16110 }
16111 else if(xoff>=6)
16112 {
16113 moveOld2(right);
16114 }
16115 else if(xoff>=1)
16116 {
16117 moveOld2(left);
16118 }
16119 }
16120 else
16121 {
16122 if(xoff>=4)
16123 {
16124 moveOld2(right);
16125 }
16126 else if(xoff<4)
16127 {
16128 moveOld2(left);
16129 }
16130 }
16131 }
16132 else
16133 {
16134 do
16135 {
16136 if(action==swimming || IsSideSwim() || action == swimhit)
16137 {
16138 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
16139
16140 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
16141 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
16142 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
16143 info.setUnwalkable(true);
16144 }
16145 else
16146 {
16147 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
16148 if(x.getInt() & 7)
16149 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
16150 else
16151 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
16152 }
16153
16154 if(info.isUnwalkable())
16155 {
16156 if(temp_y != int32_t(temp_y))
16157 {
16158 temp_y = floor((double)temp_y);
16159 }
16160 else if(temp_step > 1)
16161 {
16162 if(temp_step != int32_t(temp_step)) //floor
16163 temp_step = floor((double)temp_step);
16164 else --temp_step;
16165 }
16166 else
16167 break;
16168 }
16169 }
16170 while(info.isUnwalkable());
16171
16172 execute(info);
16173
16174 if(!info.isUnwalkable())
16175 {
16176 x = temp_x;
16177 y = temp_y;
16178 hero_newstep = temp_step;
16179 moveOld2(up);
16180 return;
16181 }
16182
16183 if(!DrunkLeft() && !DrunkRight())
16184 {
16185 if(NO_GRIDLOCK)
16186 {
16187 x = x.getInt();
16188 y = y.getInt();
16189 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16190 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16191 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16192 {
16193 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16194 sprite::move((zfix)-1,(zfix)0);
16195 }
16196 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16197 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16198 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16199 {
16200 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16201 sprite::move((zfix)1,(zfix)0);
16202 }
16203 else
16204 {
16205 pushing=push+1;
16206 }
16207 }
16208 else pushing=push+1;
16209
16210 if(charging==0 && spins==0)
16211 {
16212 dir=up;
16213 }
16214
16215 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16216 {
16217 herostep();
16218 }
16219
16220 return;
16221 }
16222 else
16223 {
16224 goto LEFTRIGHT_NEWMOVE;
16225 }
16226 }
16227
16228 return;
16229 }
16230
16231 if(DrunkDown())
16232 {
16233 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16234 {
16235 if(dir!=up && dir!=down)
16236 {
16237 if(xoff>2&&xoff<6)
16238 {
16239 moveOld2(dir);
16240 }
16241 else if(xoff>=6)
16242 {
16243 moveOld2(right);
16244 }
16245 else if(xoff>=1)
16246 {
16247 moveOld2(left);
16248 }
16249 }
16250 else
16251 {
16252 if(xoff>=4)
16253 {
16254 moveOld2(right);
16255 }
16256 else if(xoff<4)
16257 {
16258 moveOld2(left);
16259 }
16260 }
16261 }
16262 else
16263 {
16264 do
16265 {
16266 if(action==swimming || IsSideSwim() || action == swimhit)
16267 {
16268 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16269
16270 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
16271 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
16272 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
16273 info.setUnwalkable(true);
16274 }
16275 else
16276 {
16277 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16278 if(x.getInt() & 7)
16279 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
16280 else
16281 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
16282 }
16283
16284 if(info.isUnwalkable())
16285 {
16286 if(temp_y != int32_t(temp_y))
16287 {
16288 temp_y = floor((double)temp_y);
16289 }
16290 else if(temp_step > 1)
16291 {
16292 if(temp_step != int32_t(temp_step)) //floor
16293 temp_step = floor((double)temp_step);
16294 else --temp_step;
16295 }
16296 else
16297 break;
16298 }
16299 }
16300 while(info.isUnwalkable());
16301
16302 execute(info);
16303
16304 if(!info.isUnwalkable())
16305 {
16306 x = temp_x;
16307 y = temp_y;
16308 hero_newstep = temp_step;
16309 moveOld2(down);
16310 return;
16311 }
16312
16313 if(!DrunkLeft() && !DrunkRight())
16314 {
16315 if(NO_GRIDLOCK)
16316 {
16317 x = x.getInt();
16318 y = y.getInt();
16319 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16320 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16321 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16322 {
16323 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16324 sprite::move((zfix)-1,(zfix)0);
16325 }
16326 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16327 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16328 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16329 {
16330 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16331 sprite::move((zfix)1,(zfix)0);
16332 }
16333 else
16334 {
16335 pushing=push+1;
16336 }
16337 }
16338 else pushing=push+1;
16339
16340 if(charging==0 && spins==0)
16341 {
16342 dir=down;
16343 }
16344
16345 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16346 {
16347 herostep();
16348 }
16349
16350 return;
16351 }
16352 else goto LEFTRIGHT_NEWMOVE;
16353 }
16354
16355 return;
16356 }
16357
16358 LEFTRIGHT_NEWMOVE:
16359 temp_x = x;
16360 temp_y = y;
16361 temp_step = hero_newstep;
16362 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16363 {
16364 return;
16365 }
16366
16367 if(DrunkLeft())
16368 {
16369 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16370 {
16371 if(dir!=left && dir!=right)
16372 {
16373 if(yoff>2&&yoff<6)
16374 {
16375 moveOld2(dir);
16376 }
16377 else if(yoff>=6)
16378 {
16379 moveOld2(down);
16380 }
16381 else if(yoff>=1)
16382 {
16383 moveOld2(up);
16384 }
16385 }
16386 else
16387 {
16388 if(yoff>=4)
16389 {
16390 moveOld2(down);
16391 }
16392 else if(yoff<4)
16393 {
16394 moveOld2(up);
16395 }
16396 }
16397 }
16398 else
16399 {
16400 do
16401 {
16402 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
16403 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
16404
16405 if(y.getInt() & 7)
16406 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
16407
16408 if(info.isUnwalkable())
16409 {
16410 if(temp_x != int32_t(temp_x))
16411 {
16412 temp_x = floor((double)temp_x);
16413 }
16414 else if(temp_step > 1)
16415 {
16416 if(temp_step != int32_t(temp_step)) //floor
16417 temp_step = floor((double)temp_step);
16418 else --temp_step;
16419 }
16420 else
16421 break;
16422 }
16423 }
16424 while(info.isUnwalkable());
16425
16426 execute(info);
16427
16428 if(!info.isUnwalkable())
16429 {
16430 x = temp_x;
16431 y = temp_y;
16432 hero_newstep = temp_step;
16433 moveOld2(left);
16434 return;
16435 }
16436
16437 if(!DrunkUp() && !DrunkDown())
16438 {
16439 if(NO_GRIDLOCK)
16440 {
16441 x = x.getInt();
16442 y = y.getInt();
16443 int32_t v1=bigHitbox?0:8;
16444 int32_t v2=bigHitbox?8:12;
16445
16446 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16447 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16448 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16449 {
16450 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16451 sprite::move((zfix)0,(zfix)-1);
16452 }
16453 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16454 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16455 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16456 {
16457 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16458 sprite::move((zfix)0,(zfix)1);
16459 }
16460 else
16461 {
16462 pushing=push+1;
16463 }
16464 }
16465 else pushing=push+1;
16466
16467 if(charging==0 && spins==0)
16468 {
16469 dir=left;
16470 }
16471
16472 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16473 {
16474 herostep();
16475 }
16476
16477 return;
16478 }
16479 }
16480
16481 return;
16482 }
16483
16484 if(DrunkRight())
16485 {
16486 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16487 {
16488 if(dir!=left && dir!=right)
16489 {
16490 if(yoff>2&&yoff<6)
16491 {
16492 moveOld2(dir);
16493 }
16494 else if(yoff>=6)
16495 {
16496 moveOld2(down);
16497 }
16498 else if(yoff>=1)
16499 {
16500 moveOld2(up);
16501 }
16502 }
16503 else
16504 {
16505 if(yoff>=4)
16506 {
16507 moveOld2(down);
16508 }
16509 else if(yoff<4)
16510 {
16511 moveOld2(up);
16512 }
16513 }
16514 }
16515 else
16516 {
16517 do
16518 {
16519 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16520 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
16521
16522 if(y.getInt() & 7)
16523 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
16524
16525 if(info.isUnwalkable())
16526 {
16527 if(temp_x != int32_t(temp_x))
16528 {
16529 temp_x = floor((double)temp_x);
16530 }
16531 else if(temp_step > 1)
16532 {
16533 if(temp_step != int32_t(temp_step)) //floor
16534 temp_step = floor((double)temp_step);
16535 else --temp_step;
16536 }
16537 else
16538 break;
16539 }
16540 }
16541 while(info.isUnwalkable());
16542
16543 execute(info);
16544
16545 if(!info.isUnwalkable())
16546 {
16547 x = temp_x;
16548 y = temp_y;
16549 hero_newstep = temp_step;
16550 moveOld2(right);
16551 return;
16552 }
16553
16554 if(!DrunkUp() && !DrunkDown())
16555 {
16556 if(NO_GRIDLOCK)
16557 {
16558 x = x.getInt();
16559 y = y.getInt();
16560 int32_t v1=bigHitbox?0:8;
16561 int32_t v2=bigHitbox?8:12;
16562
16563 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16564 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16565 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16566 {
16567 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16568 sprite::move((zfix)0,(zfix)-1);
16569 }
16570 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16571 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16572 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16573 {
16574 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16575 sprite::move((zfix)0,(zfix)1);
16576 }
16577 else
16578 {
16579 pushing=push+1;
16580 }
16581 }
16582 else pushing=push+1;
16583
16584 if(charging==0 && spins==0)
16585 {
16586 dir=right;
16587 }
16588
16589 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16590 {
16591 herostep();
16592 }
16593
16594 return;
16595 }
16596 }
16597 }
16598 }
16599 else
16600 {
16601 4571658 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16602 2285829 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
16603
16604
10/10
✓ Branch 0 taken 1444421 times.
✓ Branch 1 taken 841408 times.
✓ Branch 2 taken 178265 times.
✓ Branch 3 taken 1266156 times.
✓ Branch 4 taken 102611 times.
✓ Branch 5 taken 75654 times.
✓ Branch 6 taken 927 times.
✓ Branch 7 taken 101684 times.
✓ Branch 8 taken 842 times.
✓ Branch 9 taken 85 times.
2285829 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
16605 {
16606 //ONLY process the side-effects of the above walkflag if Hero will actually move
16607 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16608 842 execute(info);
16609 842 moveOld2(left);
16610 842 return;
16611 }
16612
16613 4569974 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
16614 2284987 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
16615
16616
10/10
✓ Branch 0 taken 1443579 times.
✓ Branch 1 taken 841408 times.
✓ Branch 2 taken 198489 times.
✓ Branch 3 taken 1245090 times.
✓ Branch 4 taken 111526 times.
✓ Branch 5 taken 86963 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 110380 times.
✓ Branch 8 taken 88 times.
✓ Branch 9 taken 1058 times.
2284987 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
16617 {
16618 1058 execute(info);
16619 1058 moveOld2(right);
16620 1058 return;
16621 }
16622
16623 2283929 ladderx = oldladderx;
16624 2283929 laddery = oldladdery;
16625
16626
2/2
✓ Branch 0 taken 246085 times.
✓ Branch 1 taken 2037844 times.
2283929 if(DrunkUp())
16627 {
16628
11/14
✓ Branch 0 taken 6732 times.
✓ Branch 1 taken 239353 times.
✓ Branch 2 taken 6279 times.
✓ Branch 3 taken 453 times.
✓ Branch 4 taken 5253 times.
✓ Branch 5 taken 1026 times.
✓ Branch 6 taken 5253 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5253 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5253 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 5250 times.
246085 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16629 {
16630
3/4
✓ Branch 0 taken 5217 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5217 times.
5250 if(dir!=up && dir!=down)
16631 {
16632
4/4
✓ Branch 0 taken 3611 times.
✓ Branch 1 taken 1606 times.
✓ Branch 2 taken 1553 times.
✓ Branch 3 taken 2058 times.
5217 if(xoff>2&&xoff<6)
16633 {
16634 2058 moveOld2(dir);
16635 2058 }
16636
2/2
✓ Branch 0 taken 1553 times.
✓ Branch 1 taken 1606 times.
3159 else if(xoff>=6)
16637 {
16638 1553 moveOld2(right);
16639 1553 }
16640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1606 times.
1606 else if(xoff>=1)
16641 {
16642 1606 moveOld2(left);
16643 1606 }
16644 5217 }
16645 else
16646 {
16647
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 if(xoff>=4)
16648 {
16649 10 moveOld2(right);
16650 10 }
16651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 else if(xoff<4)
16652 {
16653 23 moveOld2(left);
16654 23 }
16655 }
16656 5250 }
16657 else
16658 {
16659
4/6
✓ Branch 0 taken 229449 times.
✓ Branch 1 taken 11386 times.
✓ Branch 2 taken 229449 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 229449 times.
240835 if(action==swimming || IsSideSwim() || action == swimhit)
16660 {
16661 11386 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16662
16663
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11386 times.
✓ Branch 4 taken 944 times.
✓ Branch 5 taken 10442 times.
✓ Branch 6 taken 8870 times.
✓ Branch 7 taken 2516 times.
21828 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16664
2/2
✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 7954 times.
18396 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
16665 7954 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
16666 2516 info.setUnwalkable(true);
16667 11386 }
16668 else
16669 {
16670 229449 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16671
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 228992 times.
229449 if(x.getInt() & 7)
16672 457 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
16673 else
16674 228992 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
16675 }
16676
16677 240835 execute(info);
16678
16679
2/2
✓ Branch 0 taken 109203 times.
✓ Branch 1 taken 131632 times.
240835 if(!info.isUnwalkable())
16680 {
16681 131632 moveOld2(up);
16682 131632 return;
16683 }
16684
16685
4/4
✓ Branch 0 taken 98281 times.
✓ Branch 1 taken 10922 times.
✓ Branch 2 taken 11154 times.
✓ Branch 3 taken 87127 times.
109203 if(!DrunkLeft() && !DrunkRight())
16686 {
16687
2/4
✓ Branch 0 taken 87127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87127 times.
✗ Branch 3 not taken.
87127 if(NO_GRIDLOCK)
16688 {
16689 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16690 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16691 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16692 {
16693 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16694 sprite::move((zfix)-1,(zfix)0);
16695 }
16696 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16697 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16698 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16699 {
16700 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16701 sprite::move((zfix)1,(zfix)0);
16702 }
16703 else
16704 {
16705 pushing=push+1;
16706 }
16707 }
16708 87127 else pushing=push+1;
16709
16710
4/4
✓ Branch 0 taken 86944 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 86848 times.
✓ Branch 3 taken 96 times.
87127 if(charging==0 && spins==0)
16711 {
16712 86848 dir=up;
16713 86848 }
16714
16715
5/8
✓ Branch 0 taken 85227 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 85227 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85227 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 85227 times.
87127 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16716 {
16717 85227 herostep();
16718 85227 }
16719
16720 87127 return;
16721 }
16722 else
16723 {
16724 22076 goto LEFTRIGHT_OLDMOVE;
16725 }
16726 }
16727
16728 5250 return;
16729 }
16730
16731
2/2
✓ Branch 0 taken 217341 times.
✓ Branch 1 taken 1820503 times.
2037844 if(DrunkDown())
16732 {
16733
11/14
✓ Branch 0 taken 6486 times.
✓ Branch 1 taken 210855 times.
✓ Branch 2 taken 6213 times.
✓ Branch 3 taken 273 times.
✓ Branch 4 taken 4178 times.
✓ Branch 5 taken 2035 times.
✓ Branch 6 taken 4178 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4178 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4178 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 4177 times.
217341 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16734 {
16735
3/4
✓ Branch 0 taken 4177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4176 times.
4177 if(dir!=up && dir!=down)
16736 {
16737
4/4
✓ Branch 0 taken 2932 times.
✓ Branch 1 taken 1244 times.
✓ Branch 2 taken 1236 times.
✓ Branch 3 taken 1696 times.
4176 if(xoff>2&&xoff<6)
16738 {
16739 1696 moveOld2(dir);
16740 1696 }
16741
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 1244 times.
2480 else if(xoff>=6)
16742 {
16743 1236 moveOld2(right);
16744 1236 }
16745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1244 times.
1244 else if(xoff>=1)
16746 {
16747 1244 moveOld2(left);
16748 1244 }
16749 4176 }
16750 else
16751 {
16752
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(xoff>=4)
16753 {
16754 1 moveOld2(right);
16755 1 }
16756 else if(xoff<4)
16757 {
16758 moveOld2(left);
16759 }
16760 }
16761 4177 }
16762 else
16763 {
16764
4/6
✓ Branch 0 taken 200600 times.
✓ Branch 1 taken 12564 times.
✓ Branch 2 taken 200600 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 200600 times.
213164 if(action==swimming || IsSideSwim() || action == swimhit)
16765 {
16766 12564 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16767
16768
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 12564 times.
✓ Branch 2 taken 12564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 893 times.
✓ Branch 5 taken 11671 times.
✓ Branch 6 taken 8139 times.
✓ Branch 7 taken 4425 times.
24235 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16769
2/2
✓ Branch 0 taken 4353 times.
✓ Branch 1 taken 7318 times.
18989 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
16770 7318 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
16771 4425 info.setUnwalkable(true);
16772 12564 }
16773 else
16774 {
16775 200600 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16776
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 200325 times.
200600 if(x.getInt() & 7)
16777 275 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
16778 else
16779 200325 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
16780 }
16781
16782 213164 execute(info);
16783
16784
2/2
✓ Branch 0 taken 103643 times.
✓ Branch 1 taken 109521 times.
213164 if(!info.isUnwalkable())
16785 {
16786 109521 moveOld2(down);
16787 109521 return;
16788 }
16789
16790
4/4
✓ Branch 0 taken 91876 times.
✓ Branch 1 taken 11767 times.
✓ Branch 2 taken 11308 times.
✓ Branch 3 taken 80568 times.
103643 if(!DrunkLeft() && !DrunkRight())
16791 {
16792
2/4
✓ Branch 0 taken 80568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80568 times.
✗ Branch 3 not taken.
80568 if(NO_GRIDLOCK)
16793 {
16794 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16795 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16796 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16797 {
16798 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16799 sprite::move((zfix)-1,(zfix)0);
16800 }
16801 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16802 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16803 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16804 {
16805 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16806 sprite::move((zfix)1,(zfix)0);
16807 }
16808 else
16809 {
16810 pushing=push+1;
16811 }
16812 }
16813 80568 else pushing=push+1;
16814
16815
2/4
✓ Branch 0 taken 80568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80568 times.
✗ Branch 3 not taken.
80568 if(charging==0 && spins==0)
16816 {
16817 80568 dir=down;
16818 80568 }
16819
16820
5/8
✓ Branch 0 taken 78600 times.
✓ Branch 1 taken 1968 times.
✓ Branch 2 taken 78600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78600 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 78600 times.
80568 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16821 {
16822 78600 herostep();
16823 78600 }
16824
16825 80568 return;
16826 }
16827 23075 else goto LEFTRIGHT_OLDMOVE;
16828 }
16829
16830 4177 return;
16831 }
16832
16833 LEFTRIGHT_OLDMOVE:
16834
16835
7/8
✓ Branch 0 taken 1211438 times.
✓ Branch 1 taken 697986 times.
✓ Branch 2 taken 1176053 times.
✓ Branch 3 taken 35385 times.
✓ Branch 4 taken 44836 times.
✓ Branch 5 taken 1166602 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 44836 times.
1909424 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16836 {
16837 44836 return;
16838 }
16839
16840
2/2
✓ Branch 0 taken 278455 times.
✓ Branch 1 taken 1586133 times.
1864588 if(DrunkLeft())
16841 {
16842
11/14
✓ Branch 0 taken 4749 times.
✓ Branch 1 taken 273706 times.
✓ Branch 2 taken 4715 times.
✓ Branch 3 taken 34 times.
✓ Branch 4 taken 4444 times.
✓ Branch 5 taken 271 times.
✓ Branch 6 taken 4444 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4444 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4444 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 4442 times.
278455 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16843 {
16844
3/4
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4437 times.
4442 if(dir!=left && dir!=right)
16845 {
16846
4/4
✓ Branch 0 taken 3161 times.
✓ Branch 1 taken 1276 times.
✓ Branch 2 taken 1345 times.
✓ Branch 3 taken 1816 times.
4437 if(yoff>2&&yoff<6)
16847 {
16848 1816 moveOld2(dir);
16849 1816 }
16850
2/2
✓ Branch 0 taken 1345 times.
✓ Branch 1 taken 1276 times.
2621 else if(yoff>=6)
16851 {
16852 1345 moveOld2(down);
16853 1345 }
16854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1276 times.
1276 else if(yoff>=1)
16855 {
16856 1276 moveOld2(up);
16857 1276 }
16858 4437 }
16859 else
16860 {
16861
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(yoff>=4)
16862 {
16863 5 moveOld2(down);
16864 5 }
16865 else if(yoff<4)
16866 {
16867 moveOld2(up);
16868 }
16869 }
16870 4442 }
16871 else
16872 {
16873 548026 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16874 274013 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
16875
16876 274013 execute(info);
16877
16878
2/2
✓ Branch 0 taken 110607 times.
✓ Branch 1 taken 163406 times.
274013 if(!info.isUnwalkable())
16879 {
16880 163406 moveOld2(left);
16881 163406 return;
16882 }
16883
16884
4/4
✓ Branch 0 taken 105025 times.
✓ Branch 1 taken 5582 times.
✓ Branch 2 taken 6065 times.
✓ Branch 3 taken 98960 times.
110607 if(!DrunkUp() && !DrunkDown())
16885 {
16886
2/4
✓ Branch 0 taken 98960 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98960 times.
98960 if(NO_GRIDLOCK)
16887 {
16888 int32_t v1=bigHitbox?0:8;
16889 int32_t v2=bigHitbox?8:12;
16890
16891 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16892 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16893 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16894 {
16895 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16896 sprite::move((zfix)0,(zfix)-1);
16897 }
16898 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16899 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16900 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16901 {
16902 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16903 sprite::move((zfix)0,(zfix)1);
16904 }
16905 else
16906 {
16907 pushing=push+1;
16908 }
16909 }
16910 98960 else pushing=push+1;
16911
16912
3/4
✓ Branch 0 taken 98954 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98954 times.
98960 if(charging==0 && spins==0)
16913 {
16914 98954 dir=left;
16915 98954 }
16916
16917
5/8
✓ Branch 0 taken 95979 times.
✓ Branch 1 taken 2981 times.
✓ Branch 2 taken 95979 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 95979 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 95979 times.
98960 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16918 {
16919 95979 herostep();
16920 95979 }
16921
16922 98960 return;
16923 }
16924 }
16925
16926 16089 return;
16927 }
16928
16929
2/2
✓ Branch 0 taken 1287657 times.
✓ Branch 1 taken 298476 times.
1586133 if(DrunkRight())
16930 {
16931
10/14
✓ Branch 0 taken 4795 times.
✓ Branch 1 taken 293681 times.
✓ Branch 2 taken 4674 times.
✓ Branch 3 taken 121 times.
✓ Branch 4 taken 4569 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 4569 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4569 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4569 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 4569 times.
298476 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16932 {
16933
4/4
✓ Branch 0 taken 4566 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 4563 times.
4569 if(dir!=left && dir!=right)
16934 {
16935
4/4
✓ Branch 0 taken 3247 times.
✓ Branch 1 taken 1316 times.
✓ Branch 2 taken 1372 times.
✓ Branch 3 taken 1875 times.
4563 if(yoff>2&&yoff<6)
16936 {
16937 1875 moveOld2(dir);
16938 1875 }
16939
2/2
✓ Branch 0 taken 1372 times.
✓ Branch 1 taken 1316 times.
2688 else if(yoff>=6)
16940 {
16941 1372 moveOld2(down);
16942 1372 }
16943
1/2
✓ Branch 0 taken 1316 times.
✗ Branch 1 not taken.
1316 else if(yoff>=1)
16944 {
16945 1316 moveOld2(up);
16946 1316 }
16947 4563 }
16948 else
16949 {
16950
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 if(yoff>=4)
16951 {
16952 1 moveOld2(down);
16953 1 }
16954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(yoff<4)
16955 {
16956 5 moveOld2(up);
16957 5 }
16958 }
16959 4569 }
16960 else
16961 {
16962 587814 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
16963 293907 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
16964
16965 293907 execute(info);
16966
16967
2/2
✓ Branch 0 taken 118080 times.
✓ Branch 1 taken 175827 times.
293907 if(!info.isUnwalkable())
16968 {
16969 175827 moveOld2(right);
16970 175827 return;
16971 }
16972
16973
4/4
✓ Branch 0 taken 113333 times.
✓ Branch 1 taken 4747 times.
✓ Branch 2 taken 5143 times.
✓ Branch 3 taken 108190 times.
118080 if(!DrunkUp() && !DrunkDown())
16974 {
16975
2/4
✓ Branch 0 taken 108190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108190 times.
108190 if(NO_GRIDLOCK)
16976 {
16977 int32_t v1=bigHitbox?0:8;
16978 int32_t v2=bigHitbox?8:12;
16979
16980 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16981 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16982 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16983 {
16984 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16985 sprite::move((zfix)0,(zfix)-1);
16986 }
16987 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16988 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16989 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16990 {
16991 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16992 sprite::move((zfix)0,(zfix)1);
16993 }
16994 else
16995 {
16996 pushing=push+1;
16997 }
16998 }
16999 108190 else pushing=push+1;
17000
17001
2/4
✓ Branch 0 taken 108190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108190 times.
108190 if(charging==0 && spins==0)
17002 {
17003 108190 dir=right;
17004 108190 }
17005
17006
5/8
✓ Branch 0 taken 107215 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 107215 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107215 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 107215 times.
108190 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17007 {
17008 107215 herostep();
17009 107215 }
17010
17011 108190 return;
17012 }
17013 }
17014 14459 }
17015 }
17016 6177406 }
17017
17018 49271 bool HeroClass::scr_walkflag(int dx,int dy,int d2,int mx,int my,bool kb)
17019 {
17020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
49271 if(toogam) return false;
17021
17022
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49271 if(blockpath && dy<80) //Blocked top parts of rooms
17023 return true;
17024
17025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49271 if(blockmoving && mblock2.hit(dx,dy,0,1,1,1))
17026 return true;
17027 //collide_object handled in scr_canmove
17028
17029
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 49271 times.
49271 if(isdungeon() && currscr<128 && dy<32
17030 && ((x<=112||x>=128) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17031 && !get_bit(quest_rules,qr_FREEFORM))
17032 return false; //Old NES dungeon stuff
17033
17034
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49271 times.
49271 bool solid = _walkflag(dx,dy,1,SWITCHBLOCK_STATE);
17035
17036
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
49271 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
17037 {
17038 if(mx>=112&&mx<120&&my<40&&my>=32)
17039 solid=true;
17040
17041 if(mx>=136&&mx<144&&my<40&&my>=32)
17042 solid=true;
17043 }
17044
17045
2/4
✓ Branch 0 taken 49271 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49271 times.
49271 if(action==swimming || IsSideSwim())
17046 {
17047 if(!solid)
17048 {
17049 bool isthissolid = false;
17050 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17051 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
17052 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17053 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17054 isthissolid = true;
17055 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
17056
17057 int ls = 22;
17058 if((get_bit(quest_rules,qr_DROWN) && isSwimming()) || (!diagonalMovement) || get_bit(quest_rules,qr_NO_HOPPING))
17059 ls = 1;
17060 if(landswim < ls)
17061 {
17062 if(mx<0||my<0);
17063 else if(mx>248);
17064 else if(mx>240);
17065 else if(my>168);
17066 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
17067 else if(iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17068 solid = false;
17069 else
17070 solid = true;
17071 }
17072 }
17073 else
17074 {
17075 int32_t wtrx = iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my);
17076 int32_t wtrx8 = iswaterex(MAPCOMBO(mx+8,my), currmap, currscr, -1, mx+8,my);
17077
17078 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17079 solid = false;
17080 }
17081 }
17082
1/2
✓ Branch 0 taken 49271 times.
✗ Branch 1 not taken.
49271 else if(ladderx+laddery) // ladder is being used
17083 {
17084 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(mx) : x;
17085 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(my) : y;
17086
17087 if(ladderdir==up)
17088 {
17089 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17090 {
17091 bool temp = false;
17092
17093 if(!(abs(lx-(ladderx+8))<=8))
17094 temp = true;
17095
17096 if(!(abs((lx+8)-(ladderx+8))<=8))
17097 temp=true;
17098
17099 if(!temp)
17100 {
17101 solid = false;
17102 }
17103 else if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17104 {
17105 solid = true;
17106 }
17107 }
17108 }
17109 else
17110 {
17111 if(abs(lx-(ladderx+8))<=8)
17112 {
17113 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17114 {
17115 solid = false;
17116 }
17117 else if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17118 {
17119 solid = true;
17120 }
17121 else if((abs(ly-laddery+8)<=8) && d2<=down)
17122 {
17123 solid = false;
17124 }
17125 }
17126 }
17127 }
17128
5/6
✓ Branch 0 taken 42892 times.
✓ Branch 1 taken 6379 times.
✓ Branch 2 taken 15344 times.
✓ Branch 3 taken 27548 times.
✓ Branch 4 taken 15344 times.
✗ Branch 5 not taken.
49271 else if(solid || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
17129 {
17130 // see if it's a good spot for the ladder or for swimming
17131
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49271 times.
49271 bool unwalkablex = _walkflag(mx,my,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
17132
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49271 times.
49271 bool unwalkablex8 = _walkflag(mx+8,my,1,SWITCHBLOCK_STATE);
17133
17134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
49271 if(get_bit(quest_rules, qr_DROWN))
17135 {
17136 // Drowning changes the following attributes:
17137 // * Dangerous water is also walkable, so ignore the previous
17138 // definitions of unwalkablex and unwalkablex8.
17139 // * Instead, prevent the ladder from being used in the
17140 // one frame where Hero has landed on water before drowning.
17141 49271 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
17142 49271 }
17143
17144 // check if he can swim
17145
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
49271 if(current_item(itype_flippers) && z==0 && fakez==0)
17146 {
17147 int32_t wtrx = iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my);
17148 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,my), currmap, currscr, -1, mx+8,my);
17149 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
17150 {
17151 //ladder ignores water combos that are now walkable thanks to flippers -DD
17152 unwalkablex = unwalkablex && (!wtrx);
17153 unwalkablex8 = unwalkablex8 && (!wtrx8);
17154
17155 if(landswim >= 22)
17156 {
17157 solid = false;
17158 }
17159 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17160 {
17161 if(dir==d2)
17162 {
17163 ladderx = 0;
17164 laddery = 0;
17165 }
17166 }
17167 }
17168 }
17169
17170 // check if he can use the ladder
17171 // "Allow Ladder Anywhere" is toggled by fLADDER
17172
1/2
✓ Branch 0 taken 49271 times.
✗ Branch 1 not taken.
49271 if(can_deploy_ladder())
17173 // laddersetup
17174 {
17175 // Check if there's water to use the ladder over
17176 bool wtrx = (iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my) != 0);
17177 bool wtrx8 = (iswaterex(MAPCOMBO(mx+8,my), currmap, currscr, -1, mx+8,my) != 0);
17178 int32_t ldrid = current_item_id(itype_ladder);
17179 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
17180
17181 if(wtrx || wtrx8)
17182 {
17183 if(isSideViewHero())
17184 {
17185 wtrx = !_walkflag(mx, my+8, 1,SWITCHBLOCK_STATE) && !_walkflag(mx, my, 1,SWITCHBLOCK_STATE) && dir!=down;
17186 wtrx8 = !_walkflag(mx+8, my+8, 1,SWITCHBLOCK_STATE) && !_walkflag(mx+8, my, 1,SWITCHBLOCK_STATE) && dir!=down;
17187 }
17188 // * walk on half-water using the ladder instead of using flippers.
17189 // * otherwise, walk on ladder(+hookshot) combos.
17190 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(mx, my)) || isstepable(MAPCOMBO(mx+8,my)) || wtrx==true))
17191 {
17192 if(!get_bit(quest_rules, qr_OLD_210_WATER))
17193 {
17194 //if Hero could swim on a tile instead of using the ladder,
17195 //refuse to use the ladder to step over that tile. -DD
17196 wtrx = isstepable(MAPCOMBO(mx, my)) && unwalkablex;
17197 wtrx8 = isstepable(MAPCOMBO(mx+8,my)) && unwalkablex8;
17198 }
17199 }
17200 }
17201 else
17202 {
17203 // No water; check other things
17204
17205 //Check pits
17206 if(ladderpits)
17207 {
17208 int32_t pit_cmb = getpitfall(mx,my);
17209 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17210 pit_cmb = getpitfall(mx+8,my);
17211 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17212 }
17213 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
17214 {
17215 int32_t combo=combobuf[MAPCOMBO(mx, my)].type;
17216 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17217 combo=combobuf[MAPCOMBO(mx+8, my)].type;
17218 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17219 }
17220 }
17221
17222 for (int32_t i = 0; i <= 1; ++i)
17223 {
17224 if(tmpscr2[i].valid!=0)
17225 {
17226 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
17227 {
17228 if (combobuf[MAPCOMBO2(i,mx,my)].type == cBRIDGE && !_walkflag_layer(mx,my,1, &(tmpscr2[i]))) wtrx = false;
17229 if (combobuf[MAPCOMBO2(i,mx+8,my)].type == cBRIDGE && !_walkflag_layer(mx+8,my,1, &(tmpscr2[i]))) wtrx8 = false;
17230 }
17231 else
17232 {
17233 if (combobuf[MAPCOMBO2(i,mx,my)].type == cBRIDGE && _effectflag_layer(mx,my,1, &(tmpscr2[i]))) wtrx = false;
17234 if (combobuf[MAPCOMBO2(i,mx+8,my)].type == cBRIDGE && _effectflag_layer(mx+8,my,1, &(tmpscr2[i]))) wtrx8 = false;
17235 }
17236 }
17237 }
17238 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(mx,my), currmap, currscr, -1, mx,my));
17239
17240 if(d2==dir)
17241 {
17242 int32_t c = walkwater ? 0:8;
17243 int32_t b = walkwater ? 8:0;
17244
17245 if(d2>=left)
17246 {
17247 // If the difference between my and y is small enough
17248 if(abs((my)-(int32_t(y+c)))<=(b) && wtrx)
17249 {
17250 // Don't activate the ladder if it would be entirely
17251 // over water and Hero has the flippers. This isn't
17252 // a good way to do this, but it's too risky
17253 // to make big changes to this stuff.
17254 bool deployLadder=true;
17255 int32_t lx=mx&0xF0;
17256 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17257 {
17258 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
17259 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
17260 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
17261 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
17262 deployLadder=false;
17263 }
17264 if(deployLadder)
17265 {
17266 ladderx = mx&0xF0;
17267 laddery = y;
17268 ladderdir = left;
17269 ladderstart = d2;
17270 solid = laddery!=y.getInt();
17271 }
17272 }
17273 }
17274 else if(d2<=down)
17275 {
17276 // If the difference between mx and x is small enough
17277 if(abs((mx)-(int32_t(x+c)))<=(b) && wtrx)
17278 {
17279 ladderx = x;
17280 laddery = my&0xF0;
17281 ladderdir = up;
17282 ladderstart = d2;
17283 solid = ladderx!=x.getInt();
17284 }
17285 else if(abs((mx+8)-(int32_t(x+c)))<=(b) && wtrx8)
17286 {
17287 ladderx = x;
17288 laddery = my&0xF0;
17289 ladderdir = up;
17290 ladderstart = d2;
17291 solid = ladderx!=x.getInt();
17292 }
17293 }
17294 }
17295 }
17296 49271 }
17297
17298 49271 return solid;
17299 49271 }
17300
17301 24291 bool HeroClass::scr_canmove(zfix dx, zfix dy, bool kb, bool ign_sv)
17302 {
17303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24291 times.
24291 if(toogam) return true;
17304
3/4
✓ Branch 0 taken 4407 times.
✓ Branch 1 taken 19884 times.
✓ Branch 2 taken 4407 times.
✗ Branch 3 not taken.
24291 if(!(dx || dy)) return true;
17305 24291 zfix bx = x, by = y+(bigHitbox?0:8); //left/top
17306 24291 zfix rx = x+15, ry = y+15; //right/bottom
17307 24291 zfix wid = 16, hei = bigHitbox ? 16 : 8;
17308
6/14
✓ Branch 0 taken 24291 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1910 times.
✓ Branch 3 taken 22381 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 1658 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 252 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
24291 if(!ign_sv && dy < 0 && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17309 return false;
17310
17311 24291 bool nosolid = true;
17312
17313
3/4
✓ Branch 0 taken 19884 times.
✓ Branch 1 taken 4407 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19884 times.
24291 if(dx && !dy)
17314 {
17315
2/2
✓ Branch 0 taken 9563 times.
✓ Branch 1 taken 10321 times.
19884 if(dx < 0)
17316 {
17317 9563 int mx = (bx+dx).getFloor();
17318
2/2
✓ Branch 0 taken 9563 times.
✓ Branch 1 taken 8353 times.
17916 for(zfix ty = 0; by+ty < ry; ty += 8)
17319 {
17320
2/2
✓ Branch 0 taken 8353 times.
✓ Branch 1 taken 1210 times.
9563 if(scr_walkflag(mx, by+ty, left, mx, by, kb))
17321 1210 return false;
17322 8353 }
17323
2/2
✓ Branch 0 taken 823 times.
✓ Branch 1 taken 7530 times.
8353 if(scr_walkflag(mx, ry, left, mx, by, kb))
17324 823 return false;
17325
3/4
✓ Branch 0 taken 7530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3790 times.
✓ Branch 3 taken 3740 times.
7530 if(nosolid && collide_object(bx+dx,by,-dx,hei,this))
17326 3740 return false;
17327 3790 }
17328 else
17329 {
17330 10321 int mx = (rx+dx).getCeil();
17331 10321 int lx = mx-hxsz+1;
17332
2/2
✓ Branch 0 taken 10321 times.
✓ Branch 1 taken 9387 times.
19708 for(zfix ty = 0; by+ty < ry; ty += 8)
17333 {
17334
2/2
✓ Branch 0 taken 9387 times.
✓ Branch 1 taken 934 times.
10321 if(scr_walkflag(mx, by+ty, right, lx, by, kb))
17335 934 return false;
17336 9387 }
17337
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 8532 times.
9387 if(scr_walkflag(mx, ry, right, lx, by, kb))
17338 855 return false;
17339
3/4
✓ Branch 0 taken 8532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5489 times.
✓ Branch 3 taken 3043 times.
8532 if(nosolid && collide_object(bx+wid,by,dx,hei,this))
17340 3043 return false;
17341 }
17342 9279 }
17343
2/4
✓ Branch 0 taken 4407 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4407 times.
4407 else if(dy && !dx)
17344 {
17345
2/2
✓ Branch 0 taken 1910 times.
✓ Branch 1 taken 2497 times.
4407 if(dy < 0)
17346 {
17347 1910 int my = (by+dy).getFloor();
17348
2/2
✓ Branch 0 taken 3244 times.
✓ Branch 1 taken 1059 times.
4303 for(zfix tx = 0; bx+tx < rx; tx += 8)
17349 {
17350
2/2
✓ Branch 0 taken 2393 times.
✓ Branch 1 taken 851 times.
3244 if(scr_walkflag(bx+tx, my, up, bx, my, kb))
17351 851 return false;
17352 2393 }
17353
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1042 times.
1059 if(scr_walkflag(rx, my, up, bx, my, kb))
17354 17 return false;
17355
2/4
✓ Branch 0 taken 1042 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1042 times.
✗ Branch 3 not taken.
1042 if(nosolid && collide_object(bx,by+dy,wid,-dy,this))
17356 return false;
17357 1042 }
17358 else
17359 {
17360 2497 int my = (ry+dy).getCeil();
17361 2497 int ly = my-hysz+1;
17362
2/2
✓ Branch 0 taken 4015 times.
✓ Branch 1 taken 1343 times.
5358 for(zfix tx = 0; bx+tx < rx; tx += 8)
17363 {
17364
2/2
✓ Branch 0 taken 2861 times.
✓ Branch 1 taken 1154 times.
4015 if(scr_walkflag(bx+tx, my, down, bx, ly, kb))
17365 1154 return false;
17366 2861 }
17367
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 1250 times.
1343 if(scr_walkflag(rx, my, down, bx, ly, kb))
17368 93 return false;
17369
3/4
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 956 times.
1250 if(nosolid && collide_object(bx,by+hei,wid,dy,this))
17370 294 return false;
17371 }
17372 1998 }
17373 else //! Untested, and currently unused.
17374 {
17375 return scr_canmove(dx, 0, kb, ign_sv) && scr_canmove(dy, 0, kb, ign_sv);
17376 }
17377 11277 return true;
17378 24291 }
17379 11473 bool HeroClass::movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove, bool earlyret)
17380 {
17381 11473 bool ret = true;
17382
7/10
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7802 times.
✓ Branch 3 taken 3671 times.
✓ Branch 4 taken 7476 times.
✓ Branch 5 taken 326 times.
✓ Branch 6 taken 7476 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7476 times.
11473 bool sv = !ign_sv && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking;
17383
2/2
✓ Branch 0 taken 3997 times.
✓ Branch 1 taken 7476 times.
11473 if(sv)
17384 7476 dy = 0;
17385
4/4
✓ Branch 0 taken 9747 times.
✓ Branch 1 taken 1726 times.
✓ Branch 2 taken 8648 times.
✓ Branch 3 taken 1099 times.
11473 if(dx && dy)
17386 1099 shove = false;
17387 11473 bool checkladder = dy < 0;
17388
17389 11473 const int scl = 2;
17390
2/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11473 times.
11473 while(abs(dx) > scl || abs(dy) > scl)
17391 {
17392 if(abs(dx) > abs(dy))
17393 {
17394 int32_t tdx = dx.sign() * scl;
17395 if(movexy(tdx, 0, kb, ign_sv, shove, earlyret))
17396 dx -= tdx;
17397 else
17398 {
17399 if(earlyret) return false;
17400 dx = tdx;
17401 ret = false;
17402 }
17403 }
17404 else
17405 {
17406 int32_t tdy = dy.sign() * scl;
17407 if(movexy(0, tdy, kb, ign_sv, shove, earlyret))
17408 dy -= tdy;
17409 else
17410 {
17411 if(earlyret) return false;
17412 dy = tdy;
17413 ret = false;
17414 }
17415 }
17416 }
17417
17418
6/8
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 11257 times.
✓ Branch 4 taken 10893 times.
✓ Branch 5 taken 364 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 10893 times.
11473 bool skipdmg = earlyret || hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS));
17419
2/2
✓ Branch 0 taken 1726 times.
✓ Branch 1 taken 9747 times.
11473 if(dx)
17420 {
17421
2/2
✓ Branch 0 taken 9109 times.
✓ Branch 1 taken 638 times.
9747 if(scr_canmove(dx, 0, kb, ign_sv))
17422 9109 x += dx;
17423 else
17424 {
17425 638 bool stopped = true;
17426
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 582 times.
638 if(shove)
17427 {
17428
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 269 times.
582 zfix tx = (dx < 0 ? (x-1) : (x+16));
17429 582 auto mdir = GET_XDIR(dx);
17430 582 bool hit_top = scr_walkflag(tx,y,mdir,x+sign(dx),y,false);
17431 582 bool hit_mid = scr_walkflag(tx,y+8,mdir,x+sign(dx),y,false);
17432 582 bool hit_bottom = scr_walkflag(tx,y+15,mdir,x+sign(dx),y,false);
17433
4/4
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 468 times.
✓ Branch 3 taken 22 times.
582 if(!hit_mid && (hit_top!=hit_bottom))
17434 {
17435
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1 times.
22 if(hit_bottom) //shove up
17436 {
17437
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if(skipdmg || !checkdamagecombos(tx,y+15))
17438 21 y -= 1;
17439 21 }
17440 else //shove down
17441 {
17442
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(skipdmg || !checkdamagecombos(tx,y))
17443 1 y += 1;
17444 }
17445
17446
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 5 times.
22 if(scr_canmove(dx, 0, kb, ign_sv))
17447 {
17448 5 x += dx;
17449 5 stopped = false;
17450 5 }
17451 22 }
17452 582 }
17453
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 633 times.
638 if(stopped)
17454 {
17455 633 ret = false;
17456 633 int xsign = dx.sign();
17457
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 633 times.
676 while(scr_canmove(xsign, 0, kb, ign_sv))
17458 {
17459 43 x += xsign;
17460 43 dx -= xsign;
17461 }
17462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 633 times.
633 if(dx)
17463 {
17464 633 dx.doDecBound(0,-9999, 0,9999);
17465
3/6
✓ Branch 0 taken 633 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 633 times.
✗ Branch 5 not taken.
10072 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
17466
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 9317 times.
9439 if(scr_canmove(val, 0, kb, ign_sv))
17467 {
17468 122 retval = val;
17469 122 return BSEARCH_CONTINUE_AWAY0;
17470 }
17471 9317 else return BSEARCH_CONTINUE_TOWARD0;
17472 9439 });
17473 633 x += dx;
17474 633 }
17475 633 }
17476 }
17477 9747 }
17478
2/2
✓ Branch 0 taken 9439 times.
✓ Branch 1 taken 2034 times.
11473 if(dy)
17479 {
17480
2/2
✓ Branch 0 taken 1884 times.
✓ Branch 1 taken 150 times.
2034 if(scr_canmove(0, dy, kb, ign_sv))
17481 1884 y += dy;
17482 else
17483 {
17484 150 bool stopped = true;
17485
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 80 times.
150 if(shove)
17486 {
17487
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 45 times.
80 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)-1) : (y+16));
17488 80 auto mdir = GET_YDIR(dy);
17489 80 bool hit_left = scr_walkflag(x,ty,mdir,x,y+sign(dy),false);
17490 80 bool hit_mid = scr_walkflag(x+8,ty,mdir,x,y+sign(dy),false);
17491 80 bool hit_right = scr_walkflag(x+15,ty,mdir,x,y+sign(dy),false);
17492
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 20 times.
80 if(!hit_mid && (hit_left!=hit_right))
17493 {
17494
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 if(hit_right) //shove left
17495 {
17496
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if(skipdmg || !checkdamagecombos(x+15,ty))
17497 16 x -= 1;
17498 16 }
17499 else //shove right
17500 {
17501
3/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 times.
4 if(skipdmg || !checkdamagecombos(x,ty))
17502 1 x += 1;
17503 }
17504
17505
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 if(scr_canmove(0, dy, kb, ign_sv))
17506 {
17507 1 y += dy;
17508 1 stopped = false;
17509 1 }
17510 20 }
17511 80 }
17512
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 149 times.
150 if(stopped)
17513 {
17514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(earlyret) return false;
17515 149 ret = false;
17516 149 int ysign = dy.sign();
17517
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 149 times.
153 while(scr_canmove(0, ysign, kb, ign_sv))
17518 {
17519 4 y += ysign;
17520 4 dy -= ysign;
17521 }
17522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(dy)
17523 {
17524 149 dy.doDecBound(0,-9999, 0,9999);
17525
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
2349 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
17526
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 2091 times.
2200 if(scr_canmove(0, val, kb, ign_sv))
17527 {
17528 109 retval = val;
17529 109 return BSEARCH_CONTINUE_AWAY0;
17530 }
17531 2091 else return BSEARCH_CONTINUE_TOWARD0;
17532 2200 });
17533 149 y += dy;
17534 149 }
17535 149 }
17536 }
17537 2034 }
17538
17539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
11473 if(earlyret)
17540 return ret;
17541 11473 WalkflagInfo info;
17542 11473 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
17543 11473 execute(info);
17544
4/8
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7802 times.
✓ Branch 3 taken 3671 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7802 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11473 if(!ign_sv && sideview_mode() && IsSideSwim() && checkladder)
17545 {
17546 if(!iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)), currmap, currscr, -1, x, y+(bigHitbox?0:8) - 2, true, false)
17547 && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y+(bigHitbox?0:8) - 4) > 0)
17548 {
17549 if (game->get_sideswim_jump() != 0)
17550 {
17551 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
17552 sfx(WAV_ZN1SPLASH,(int32_t)x);
17553 hopclk = 0;
17554 if (charging || spins) action = attacking;
17555 else action = none;
17556 }
17557 else
17558 {
17559 movexy(0,-1*dy,false,false,false);
17560 }
17561 }
17562 }
17563 11473 return ret;
17564 11473 }
17565 bool HeroClass::can_movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove)
17566 {
17567 zfix ox(x),oy(y);
17568 bool ret = movexy(dx,dy,kb,ign_sv,shove,true);
17569 x = ox;
17570 y = oy;
17571 return ret;
17572 }
17573
17574 15396 bool HeroClass::premove()
17575 {
17576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 if(lstunclock) return false;
17577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15396 if(is_conveyor_stunned) return (convey_forcex || convey_forcey);
17578 15396 int32_t xoff=x.getInt()&7;
17579 15396 int32_t yoff=y.getInt()&7;
17580
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15396 if(NO_GRIDLOCK)
17581 {
17582 15396 xoff = 0;
17583 15396 yoff = 0;
17584 15396 }
17585 15396 int32_t push=pushing;
17586 15396 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
17587 15396 int32_t flippers_id = current_item_id(itype_flippers);
17588 15396 itemdata const& itm = itemsbuf[flippers_id];
17589 15396 byte intbtn = byte(itm.misc3&0xFF);
17590 15396 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
17591 15396 bool eatdive = false;
17592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 if(diveclk>0)
17593 {
17594 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
17595 --diveclk;
17596 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
17597 {
17598 diveclk = itemsbuf[flippers_id].misc2;
17599 eatdive = true;
17600 }
17601 }
17602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15396 else if(action == swimming && dive_pressed)
17603 {
17604 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
17605 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
17606
17607 if(global_diving==screen_diving)
17608 {
17609 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
17610 eatdive = true;
17611 }
17612 }
17613
1/2
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
15396 if(eatdive)
17614 getIntBtnInput(intbtn, true, true, false, false, false);
17615
17616
1/2
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
15396 if(action==rafting)
17617 {
17618 do_rafting();
17619
17620 if(action==rafting)
17621 {
17622 return false;
17623 }
17624
17625
17626 set_respawn_point();
17627 trySideviewLadder();
17628 }
17629
17630 15396 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
17631 15396 int32_t btnwpn = -1;
17632
17633 //&0xFFF removes the "bow & arrows" bitmask
17634 //The Quick Sword is allowed to interrupt attacks.
17635
3/4
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1947 times.
✓ Branch 3 taken 13449 times.
15396 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
17636
2/8
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15396 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15396 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
17637 {
17638
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 15312 times.
15396 if(DrunkrBbtn())
17639 {
17640 84 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
17641 84 dowpn = Bwpn&0xFFF;
17642 84 directWpn = directItemB;
17643 84 }
17644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15312 times.
15312 else if(DrunkrAbtn())
17645 {
17646 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
17647 dowpn = Awpn&0xFFF;
17648 directWpn = directItemA;
17649 }
17650
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15312 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
17651 {
17652 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
17653 dowpn = Xwpn&0xFFF;
17654 directWpn = directItemX;
17655 }
17656
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15312 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
17657 {
17658 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
17659 dowpn = Ywpn&0xFFF;
17660 directWpn = directItemY;
17661 }
17662
17663
1/2
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
15396 if(directWpn > 255) directWpn = 0;
17664
17665 // The Quick Sword only allows repeated sword or wand swings.
17666
3/8
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15396 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 15396 times.
15396 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
17667 btnwpn=-1;
17668 15396 }
17669
17670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
17671
2/12
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15396 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
15396 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
17672 {
17673 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
17674 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
17675 {
17676 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
17677 {
17678 paymagiccost(attackid,true);
17679 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
17680 }
17681 SetAttack();
17682 attack=wSword;
17683
17684 attackclk=0;
17685 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
17686
17687 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
17688 {
17689 if(!checkmagiccost(dowpn))
17690 {
17691 item_error();
17692 }
17693 else
17694 {
17695 //clear the item script stack for a new script
17696
17697 ri = &(itemScriptData[dowpn]);
17698 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
17699 ri->Clear();
17700 //itemScriptData[(dowpn & 0xFFF)].Clear();
17701 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
17702 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
17703 item_doscript[dowpn] = 1;
17704 itemscriptInitialised[dowpn] = 0;
17705 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
17706 did_scripta=true;
17707 }
17708 }
17709 }
17710 else
17711 {
17712 item_error();
17713 }
17714 }
17715 else
17716 {
17717 15396 did_scripta=false;
17718 }
17719
17720
6/10
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15396 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15396 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15396 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✓ Branch 9 taken 15077 times.
15396 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
17721 {
17722
4/4
✓ Branch 0 taken 1574 times.
✓ Branch 1 taken 13503 times.
✓ Branch 2 taken 1567 times.
✓ Branch 3 taken 7 times.
15077 if(DrunkUp() && canSideviewLadder())
17723 {
17724 7 setOnSideviewLadder(true);
17725 7 }
17726
4/4
✓ Branch 0 taken 2783 times.
✓ Branch 1 taken 12287 times.
✓ Branch 2 taken 2781 times.
✓ Branch 3 taken 2 times.
15070 else if(DrunkDown() && canSideviewLadder(true))
17727 {
17728 2 y+=1;
17729 2 setOnSideviewLadder(true);
17730 2 }
17731 15077 }
17732
17733 15396 int32_t wx=x;
17734 15396 int32_t wy=y;
17735
5/6
✓ Branch 0 taken 9339 times.
✓ Branch 1 taken 6057 times.
✓ Branch 2 taken 328 times.
✓ Branch 3 taken 15068 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 328 times.
15396 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
17736 {
17737
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
328 if((xoff==0)||diagonalMovement)
17738 {
17739
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 254 times.
328 if(DrunkUp()) dir=up;
17740
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 74 times.
328 if(DrunkDown()) dir=down;
17741 328 }
17742
17743
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
328 if((yoff==0)||diagonalMovement)
17744 {
17745
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 52 times.
328 if(DrunkLeft()) dir=left;
17746
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 40 times.
328 if(DrunkRight()) dir=right;
17747 328 }
17748 328 }
17749
17750
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1034 times.
✓ Branch 2 taken 2701 times.
✓ Branch 3 taken 4795 times.
✓ Branch 4 taken 6866 times.
15396 switch(dir)
17751 {
17752 case up:
17753 1034 wy-=16;
17754 1034 break;
17755
17756 case down:
17757 2701 wy+=16;
17758 2701 break;
17759
17760 case left:
17761 4795 wx-=16;
17762 4795 break;
17763
17764 case right:
17765 6866 wx+=16;
17766 6866 break;
17767 }
17768
17769 15396 do_lens();
17770
17771 15396 bool no_jinx = true;
17772
5/8
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 15312 times.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 84 times.
15396 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
17773 {
17774 84 bool paidmagic = false;
17775
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
17776
2/10
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
84 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
17777 {
17778 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
17779 no_jinx = checkitem_jinx(attackid);
17780 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
17781 {
17782 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
17783 paymagiccost(attackid,true);
17784 misc_internal_hero_flags |= LF_PAID_WAND_COST;
17785 }
17786 SetAttack();
17787 attack=wWand;
17788 attackclk=0;
17789 }
17790 else
17791 {
17792 item_error();
17793 }
17794 }
17795
2/8
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
17796 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
17797 {
17798 no_jinx = checkitem_jinx(dowpn);
17799 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
17800 {
17801 item_error();
17802 }
17803 else
17804 {
17805 paymagiccost(dowpn);
17806 paidmagic = true;
17807 SetAttack();
17808 attack=wHammer;
17809 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
17810 attackclk=0;
17811 }
17812 }
17813
2/8
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
17814 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
17815 {
17816 //checkbunny handled where magic cost is paid
17817 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
17818 no_jinx = checkitem_jinx(attackid);
17819 if(no_jinx)
17820 {
17821 SetAttack();
17822 attack=wFire;
17823 attackclk=0;
17824 }
17825 }
17826
2/8
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
17827 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
17828 {
17829 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
17830 no_jinx = checkitem_jinx(attackid);
17831 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
17832 {
17833 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
17834 paymagiccost(attackid,true);
17835 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
17836 }
17837 SetAttack();
17838 attack=wCByrna;
17839 attackclk=0;
17840 }
17841 else
17842 {
17843 item_error();
17844 }
17845 }
17846
2/8
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
17847 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
17848 {
17849 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
17850 no_jinx = checkitem_jinx(attackid);
17851 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
17852 {
17853 paymagiccost(attackid);
17854 SetAttack();
17855 attack = wBugNet;
17856 attackclk = 0;
17857 sfx(itemsbuf[attackid].usesound);
17858 }
17859 else
17860 {
17861 item_error();
17862 }
17863 }
17864 else
17865 {
17866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
17867 84 no_jinx = checkitem_jinx(itmid);
17868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(no_jinx)
17869 {
17870 84 paidmagic = startwpn(itmid);
17871
17872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(paidmagic)
17873 {
17874 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
17875 {
17876 ;
17877 }
17878 else
17879 {
17880 SetAttack();
17881 attackclk=0;
17882 attack=none;
17883
17884 if(btnwpn==itype_brang)
17885 {
17886 attack=wBrang;
17887 }
17888 }
17889 }
17890 else
17891 {
17892 // Weapon not started: directWpn should be reset to prev. value.
17893 84 directWpn = olddirectwpn;
17894 }
17895 84 }
17896 }
17897
17898
3/12
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 84 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
84 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
17899 {
17900 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
17901 {
17902 item_error();
17903 }
17904 else
17905 {
17906 // Only charge for magic if item's magic cost wasn't already charged
17907 // for the item's main use.
17908 if(!paidmagic && attack!=wWand)
17909 paymagiccost(dowpn);
17910 //clear the item script stack for a new script
17911 //itemScriptData[(dowpn & 0xFFF)].Clear();
17912 ri = &(itemScriptData[dowpn]);
17913 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
17914 ri->Clear();
17915 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
17916 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
17917 item_doscript[dowpn] = 1;
17918 itemscriptInitialised[dowpn] = 0;
17919 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
17920 did_scriptb=true;
17921 }
17922 }
17923
17924
6/12
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 84 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 84 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 84 times.
84 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
17925 {
17926 return false;
17927 }
17928
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(!no_jinx)
17929 did_scriptb = false;
17930 84 }
17931 else
17932 {
17933 15312 did_scriptb=false;
17934 }
17935
17936
3/6
✓ Branch 0 taken 15396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15396 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15396 times.
15396 if(attackclk || action==attacking || action==sideswimattacking)
17937 {
17938
17939 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
17940 {
17941 if((xoff==0)||diagonalMovement)
17942 {
17943 if(DrunkUp()) dir=up;
17944 if(DrunkDown()) dir=down;
17945 }
17946
17947 if((yoff==0)||diagonalMovement)
17948 {
17949 if(DrunkLeft()) dir=left;
17950 if(DrunkRight()) dir=right;
17951 }
17952 }
17953
17954 bool attacked = doattack();
17955
17956 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
17957 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
17958 {
17959 if((xoff==0)||diagonalMovement)
17960 {
17961 if(DrunkUp()) dir=up;
17962
17963 if(DrunkDown()) dir=down;
17964 }
17965
17966 if((yoff==0)||diagonalMovement)
17967 {
17968 if(DrunkLeft()) dir=left;
17969
17970 if(DrunkRight()) dir=right;
17971 }
17972 }
17973
17974 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
17975 {
17976 return false;
17977 }
17978 else if(!attacked)
17979 {
17980 // Spin attack - change direction
17981 if(spins>1 && attack != wHammer)
17982 {
17983 spins--;
17984
17985 if(spins%5==0)
17986 {
17987 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
17988 sfx(itemsbuf[id].usesound,pan(x.getInt()));
17989 }
17990 attackclk=1;
17991
17992 switch(dir)
17993 {
17994 case up:
17995 dir=left;
17996 break;
17997
17998 case right:
17999 dir=up;
18000 break;
18001
18002 case down:
18003 dir=right;
18004 break;
18005
18006 case left:
18007 dir=down;
18008 break;
18009 }
18010
18011 return false;
18012 }
18013 else
18014 {
18015 spins=0;
18016 }
18017
18018 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
18019 else {action=none; FFCore.setHeroAction(none);}
18020 attackclk=0;
18021 charging=0;
18022 }
18023 }
18024 15396 return true;
18025 15396 }
18026 15396 void HeroClass::movehero()
18027 {
18028 15396 WalkflagInfo info;
18029 15396 int32_t xoff=x.getInt()&7;
18030 15396 int32_t yoff=y.getInt()&7;
18031
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15396 if(NO_GRIDLOCK)
18032 {
18033 15396 xoff = 0;
18034 15396 yoff = 0;
18035 15396 }
18036 15396 auto push=pushing;
18037 15396 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
18038 15396 pushing=0;
18039
18040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 if(!is_conveyor_stunned) //these do not apply to conveyor auto-walk
18041 {
18042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15396 times.
15396 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
18043 return;
18044
18045
2/2
✓ Branch 0 taken 6057 times.
✓ Branch 1 taken 9339 times.
15396 if(action==walking) //still walking
18046 {
18047
9/10
✓ Branch 0 taken 7678 times.
✓ Branch 1 taken 1661 times.
✓ Branch 2 taken 5229 times.
✓ Branch 3 taken 2449 times.
✓ Branch 4 taken 3065 times.
✓ Branch 5 taken 2164 times.
✓ Branch 6 taken 166 times.
✓ Branch 7 taken 2899 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 166 times.
9339 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
18048 {
18049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if(attackclk>0) SetAttack();
18050 166 else {action = none; FFCore.setHeroAction(none);}
18051 166 hero_count=-1;
18052 166 return;
18053 }
18054
18055 9173 autostep=false;
18056 9173 } // endif (action==walking)
18057
18058
13/24
✓ Branch 0 taken 15230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15230 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15230 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15230 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 15230 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 15230 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 15230 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 15230 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 15230 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 2595 times.
✓ Branch 23 taken 12635 times.
15230 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
18059 {
18060 12635 action=none; FFCore.setHeroAction(none);
18061 12635 }
18062 15230 }
18063
18064
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15230 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15230 bool nohorz = (isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam);
18065
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15230 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15230 bool novert = (isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam);
18066
18067 15230 zfix dx, dy;
18068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15230 times.
15230 if(is_conveyor_stunned)
18069 {
18070 dx = convey_forcex;
18071 dy = convey_forcey;
18072 convey_forcex = 0;
18073 convey_forcey = 0;
18074 if(action != walking)
18075 {
18076 action = walking; FFCore.setHeroAction(walking);
18077 }
18078 }
18079
1/2
✓ Branch 0 taken 15230 times.
✗ Branch 1 not taken.
15230 else if(diagonalMovement)
18080 {
18081
5/5
✓ Branch 0 taken 3757 times.
✓ Branch 1 taken 864 times.
✓ Branch 2 taken 2013 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 5045 times.
15230 switch(holddir)
18082 {
18083 case up:
18084
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 31 times.
864 if(!Up())
18085 {
18086 31 holddir=-1;
18087 31 }
18088
18089 864 break;
18090
18091 case down:
18092
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 39 times.
2013 if(!Down())
18093 {
18094 39 holddir=-1;
18095 39 }
18096
18097 2013 break;
18098
18099 case left:
18100
2/2
✓ Branch 0 taken 3444 times.
✓ Branch 1 taken 107 times.
3551 if(!Left())
18101 {
18102 107 holddir=-1;
18103 107 }
18104
18105 3551 break;
18106
18107 case right:
18108
2/2
✓ Branch 0 taken 4906 times.
✓ Branch 1 taken 139 times.
5045 if(!Right())
18109 {
18110 139 holddir=-1;
18111 139 }
18112
18113 5045 break;
18114
18115 default:
18116 3757 break;
18117 } //end switch
18118
18119
6/6
✓ Branch 0 taken 1821 times.
✓ Branch 1 taken 13409 times.
✓ Branch 2 taken 1790 times.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 833 times.
✓ Branch 5 taken 864 times.
15230 if(DrunkUp()&&(holddir==-1||holddir==up)&&!novert)
18120 {
18121
4/10
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 864 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 864 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
864 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
18122 {
18123 864 dir=up;
18124 864 }
18125 864 holddir=up;
18126
18127
5/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 734 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 129 times.
864 if(DrunkRight()&&shiftdir!=left&&!nohorz)
18128 {
18129 129 shiftdir=right;
18130
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
129 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
18131
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
18132 129 }
18133
4/6
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 643 times.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 92 times.
735 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
18134 {
18135 92 shiftdir=left;
18136
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
92 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
18137
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
92 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
18138 92 }
18139 else
18140 {
18141 643 shiftdir=-1;
18142 }
18143 864 }
18144
6/6
✓ Branch 0 taken 2855 times.
✓ Branch 1 taken 13177 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 842 times.
✓ Branch 5 taken 2013 times.
16032 else if(DrunkDown()&&(holddir==-1||holddir==down)&&!novert)
18145 {
18146
4/10
✓ Branch 0 taken 2013 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2013 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2013 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2013 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2013 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
18147 {
18148 2013 dir=down;
18149 2013 }
18150 2013 holddir=down;
18151
18152
5/6
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 1491 times.
✓ Branch 2 taken 516 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 516 times.
2013 if(DrunkRight()&&shiftdir!=left&&!nohorz)
18153 {
18154 516 shiftdir=right;
18155
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
516 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
18156
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
516 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
18157 516 }
18158
5/6
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 1081 times.
✓ Branch 2 taken 414 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 414 times.
1497 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
18159 {
18160 414 shiftdir=left;
18161
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 414 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
414 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
18162
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 414 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
414 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
18163 414 }
18164 else
18165 {
18166 1083 shiftdir=-1;
18167 }
18168 2013 }
18169
6/6
✓ Branch 0 taken 3571 times.
✓ Branch 1 taken 10448 times.
✓ Branch 2 taken 3464 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 3551 times.
14019 else if(DrunkLeft()&&(holddir==-1||holddir==left)&&!nohorz)
18170 {
18171
3/6
✓ Branch 0 taken 3551 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3551 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3551 times.
3551 if(charging==0 && spins==0 && action != sideswimattacking)
18172 {
18173 3551 dir=left;
18174 3551 }
18175 3551 sideswimdir = left;
18176 3551 holddir=left;
18177
18178
4/6
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 3141 times.
✓ Branch 2 taken 410 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 410 times.
3551 if(DrunkUp()&&shiftdir!=down&&!novert)
18179 {
18180 410 shiftdir=up;
18181 410 }
18182
4/6
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 2827 times.
✓ Branch 2 taken 314 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 314 times.
3141 else if(DrunkDown()&&shiftdir!=up&&!novert)
18183 {
18184 314 shiftdir=down;
18185 314 }
18186 else
18187 {
18188 2827 shiftdir=-1;
18189 }
18190 3551 }
18191
5/6
✓ Branch 0 taken 5045 times.
✓ Branch 1 taken 5423 times.
✓ Branch 2 taken 4906 times.
✓ Branch 3 taken 139 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5045 times.
10468 else if(DrunkRight()&&(holddir==-1||holddir==right)&&!nohorz)
18192 {
18193
3/6
✓ Branch 0 taken 5045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5045 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5045 times.
5045 if(charging==0 && spins==0 && action != sideswimattacking)
18194 {
18195 5045 dir=right;
18196 5045 }
18197 5045 sideswimdir = right;
18198 5045 holddir=right;
18199
18200
4/6
✓ Branch 0 taken 547 times.
✓ Branch 1 taken 4498 times.
✓ Branch 2 taken 547 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 547 times.
5045 if(DrunkUp()&&shiftdir!=down&&!novert)
18201 {
18202 547 shiftdir=up;
18203 547 }
18204
4/6
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3970 times.
✓ Branch 2 taken 528 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 528 times.
4498 else if(DrunkDown()&&shiftdir!=up&&!novert)
18205 {
18206 528 shiftdir=down;
18207 528 }
18208 else
18209 {
18210 3970 shiftdir=-1;
18211 }
18212 5045 }
18213 else
18214 {
18215
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5423 if(shield_forcedir > -1 && action != rafting)
18216 dir = shield_forcedir;
18217 5423 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
18218 5423 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
18219 5423 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
18220 5423 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
18221 5423 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
18222
18223
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 5423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5423 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
18224 {
18225 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
18226 {
18227 //action=swimming;
18228 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
18229 {
18230 hopclk = 0xFF;
18231 }
18232 }
18233 }
18234 5423 return;
18235 }
18236 11473 get_move(holddir,dx,dy);
18237 11473 }
18238 else //4-way
18239 {
18240 shiftdir = -1;
18241 if(!novert)
18242 {
18243 if(DrunkUp())
18244 {
18245 holddir = dir = up;
18246 }
18247 else if(DrunkDown())
18248 {
18249 holddir = dir = down;
18250 }
18251 }
18252 else if(!nohorz)
18253 {
18254 if(DrunkLeft())
18255 {
18256 holddir = dir = left;
18257 }
18258 else if(DrunkRight())
18259 {
18260 holddir = dir = right;
18261 }
18262 }
18263 get_move(holddir,dx,dy);
18264 }
18265
18266
2/2
✓ Branch 0 taken 10691 times.
✓ Branch 1 taken 782 times.
11473 if(!new_engine_move(dx,dy))
18267 782 pushing = push+1;
18268 17062 }
18269
18270 19075 void HeroClass::get_move(int movedir, zfix& dx, zfix& dy)
18271 {
18272 19075 dx = 0; dy = 0;
18273
5/6
✓ Branch 0 taken 11473 times.
✓ Branch 1 taken 7602 times.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7602 times.
✓ Branch 5 taken 19075 times.
19075 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
18274 15204 return;
18275
18276 19075 zfix base_movepix(zfix(steprate) / 100);
18277 19075 zfix movepix(base_movepix);
18278 19075 zfix up_step(zfix(game->get_sideswim_up()) / 100);
18279 19075 zfix left_step(zfix(game->get_sideswim_side()) / 100);
18280 19075 zfix right_step(zfix(game->get_sideswim_side()) / 100);
18281 19075 zfix down_step(zfix(game->get_sideswim_down()) / 100);
18282 19075 std::vector<zfix*> steps;
18283
2/2
✓ Branch 0 taken 11473 times.
✓ Branch 1 taken 7602 times.
19075 steps.push_back(&movepix);
18284
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 steps.push_back(&up_step);
18285
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 steps.push_back(&left_step);
18286
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 steps.push_back(&right_step);
18287
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 steps.push_back(&down_step);
18288
18289
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 mod_steps(steps);
18290
18291
2/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
11473 up_step = -up_step;
18292
2/4
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
11473 left_step = -left_step;
18293
18294
18295
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 zfix step(movepix);
18296
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 zfix step_diag(movepix);
18297
18298
18299
1/2
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
11473 if (diagonalMovement)
18300 {
18301 //zprint2("Player's X is %d, Y is %d\n", x, y);
18302
6/6
✓ Branch 0 taken 10609 times.
✓ Branch 1 taken 864 times.
✓ Branch 2 taken 2049 times.
✓ Branch 3 taken 12658 times.
✓ Branch 4 taken 2371 times.
✓ Branch 5 taken 542 times.
19112 if (((movedir == up || movedir == down) && (shiftdir == left || shiftdir == right)) ||
18303
4/4
✓ Branch 0 taken 6771 times.
✓ Branch 1 taken 5887 times.
✓ Branch 2 taken 1752 times.
✓ Branch 3 taken 8523 times.
12658 (movedir == left || movedir == right) && (shiftdir == up || shiftdir == down))
18304 {
18305
4/6
✓ Branch 0 taken 2950 times.
✓ Branch 1 taken 7602 times.
✓ Branch 2 taken 2950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2950 times.
✗ Branch 5 not taken.
10552 step = STEP_DIAGONAL(step);
18306
3/6
✓ Branch 0 taken 2950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2950 times.
✗ Branch 5 not taken.
2950 up_step = STEP_DIAGONAL(up_step);
18307
3/6
✓ Branch 0 taken 2950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2950 times.
✗ Branch 5 not taken.
2950 left_step = STEP_DIAGONAL(left_step);
18308
3/6
✓ Branch 0 taken 2950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2950 times.
✗ Branch 5 not taken.
2950 right_step = STEP_DIAGONAL(right_step);
18309
3/6
✓ Branch 0 taken 2950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2950 times.
✗ Branch 5 not taken.
2950 down_step = STEP_DIAGONAL(down_step);
18310 2950 }
18311
4/5
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 2013 times.
✓ Branch 2 taken 3551 times.
✓ Branch 3 taken 5045 times.
✗ Branch 4 not taken.
11473 switch (movedir)
18312 {
18313 case up:
18314
3/3
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 643 times.
864 switch (shiftdir)
18315 {
18316 case left:
18317
4/10
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
92 dx = IsSideSwim() ? left_step : -step;
18318 92 break;
18319 case right:
18320
3/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
129 dx = IsSideSwim() ? right_step : step;
18321 129 break;
18322 }
18323
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 if (IsSideSwim())
18324 {
18325 dy = up_step;
18326 }
18327
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 else dy = -step;
18328 864 break;
18329 case down:
18330
3/3
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1083 times.
2013 switch (shiftdir)
18331 {
18332 case left:
18333
2/4
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 414 times.
✗ Branch 3 not taken.
414 dx = -step;
18334
2/6
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 414 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
414 if (IsSideSwim()) dx = left_step;
18335 414 break;
18336 case right:
18337
1/2
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
516 dx = step;
18338
2/6
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 516 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
516 if (IsSideSwim()) dx = right_step;
18339 516 break;
18340 }
18341
3/6
✓ Branch 0 taken 2013 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2013 times.
✓ Branch 4 taken 2013 times.
✗ Branch 5 not taken.
2013 dy = IsSideSwim() ? down_step : step;
18342 2013 break;
18343 case left:
18344
3/3
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 314 times.
✓ Branch 2 taken 2827 times.
3551 switch (shiftdir)
18345 {
18346 case up:
18347
2/4
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 410 times.
410 if (IsSideSwim())
18348 {
18349 dy = up_step;
18350 }
18351
2/4
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 410 times.
✗ Branch 3 not taken.
410 else dy = -step;
18352 410 break;
18353 case down:
18354
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 dy = step;
18355
2/6
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 314 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
314 if (IsSideSwim()) dy = down_step;
18356 314 break;
18357 }
18358
4/10
✓ Branch 0 taken 3551 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3551 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3551 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3551 times.
✗ Branch 9 not taken.
3551 dx = IsSideSwim() ? left_step : -step;
18359 3551 break;
18360 case right:
18361
3/3
✓ Branch 0 taken 547 times.
✓ Branch 1 taken 528 times.
✓ Branch 2 taken 3970 times.
5045 switch (shiftdir)
18362 {
18363 case up:
18364
4/8
✓ Branch 0 taken 547 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 547 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 547 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 547 times.
✗ Branch 7 not taken.
547 if (!IsSideSwim()) dy = -step;
18365
2/4
✓ Branch 0 taken 547 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 547 times.
547 if (IsSideSwim())
18366 {
18367 dy = up_step;
18368 }
18369 547 break;
18370 case down:
18371
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 dy = step;
18372
2/6
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528 if (IsSideSwim()) dy = down_step;
18373 528 break;
18374 }
18375
3/6
✓ Branch 0 taken 5045 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5045 times.
✓ Branch 4 taken 5045 times.
✗ Branch 5 not taken.
5045 dx = IsSideSwim() ? right_step : step;
18376 5045 break;
18377 };
18378 11473 }
18379 else
18380 {
18381 switch (movedir)
18382 {
18383 case up:
18384 dy = IsSideSwim() ? up_step : -step;
18385 break;
18386 case down:
18387 dy = IsSideSwim() ? down_step : step;
18388 break;
18389 case left:
18390 dx = IsSideSwim() ? left_step : -step;
18391 break;
18392 case right:
18393 dx = IsSideSwim() ? right_step : step;
18394 break;
18395 };
18396 }
18397
18398
6/20
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11473 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11473 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11473 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 11473 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
11473 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (movedir == up || movedir == down))) //!DIRECTION SET
18399 {
18400 11473 dir=movedir;
18401 11473 }
18402 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (movedir == up || movedir == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
18403 {
18404 dir = shiftdir;
18405 }
18406 26677 }
18407
18408 11473 bool HeroClass::new_engine_move(zfix dx, zfix dy) //no collision check
18409 {
18410
3/4
✓ Branch 0 taken 1726 times.
✓ Branch 1 taken 9747 times.
✓ Branch 2 taken 1726 times.
✗ Branch 3 not taken.
11473 if(!dx && !dy) return true;
18411
4/8
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11473 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11473 times.
11473 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
18412 {
18413 11473 herostep();
18414
18415 //ack... don't walk if in midair! -DD
18416
11/14
✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11109 times.
✓ Branch 5 taken 364 times.
✓ Branch 6 taken 11109 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7802 times.
✓ Branch 9 taken 3307 times.
✓ Branch 10 taken 2164 times.
✓ Branch 11 taken 5638 times.
✓ Branch 12 taken 324 times.
✓ Branch 13 taken 1840 times.
11473 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
18417 {
18418 9269 action=walking; FFCore.setHeroAction(walking);
18419 9269 }
18420
18421
2/2
✓ Branch 0 taken 10873 times.
✓ Branch 1 taken 600 times.
11473 if(++hero_count > (16*hero_animation_speed))
18422 600 hero_count=0;
18423 11473 }
18424 else if(!(frame & 1))
18425 {
18426 herostep();
18427 }
18428
18429 11473 bool ret = true;
18430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11473 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11473 if(charging==0 || attack!=wHammer)
18431 {
18432 11473 ret = movexy(dx,dy,false,false,true);
18433 11473 }
18434 11473 return ret;
18435 11473 }
18436
18437 3356947 void HeroClass::moveOld(int32_t d2)
18438 {
18439 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
18440 static bool totalskip = false;
18441
18442
3/6
✓ Branch 0 taken 3356947 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3356947 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3356947 times.
3356947 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
18443 return;
18444
18445 3356947 int32_t dx=0,dy=0;
18446 3356947 int32_t xstep=lsteps[x.getInt()&7];
18447 3356947 int32_t ystep=lsteps[y.getInt()&7];
18448 3356947 int32_t z3skip=0;
18449 3356947 int32_t z3diagskip=0;
18450
3/6
✓ Branch 0 taken 77205 times.
✓ Branch 1 taken 3279742 times.
✓ Branch 2 taken 77205 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6636689 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
18451
5/6
✓ Branch 0 taken 149353 times.
✓ Branch 1 taken 3130389 times.
✓ Branch 2 taken 81755 times.
✓ Branch 3 taken 67598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 81755 times.
3279742 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
18452
2/2
✓ Branch 0 taken 3356361 times.
✓ Branch 1 taken 586 times.
3356947 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
18453 3356947 bool is_swimming = (action == swimming);
18454
18455 //slow walk combo, or charging, moves at 2/3 speed
18456 if(
18457
4/4
✓ Branch 0 taken 3310134 times.
✓ Branch 1 taken 46813 times.
✓ Branch 2 taken 77568 times.
✓ Branch 3 taken 3232566 times.
3403760 (!is_swimming && (slowcharging ^ slowcombo))||
18458
2/2
✓ Branch 0 taken 46813 times.
✓ Branch 1 taken 3232566 times.
3279379 (is_swimming && (zinit.hero_swim_speed>60))
18459 )
18460 {
18461 124381 totalskip = false;
18462
18463
2/2
✓ Branch 0 taken 5817 times.
✓ Branch 1 taken 118564 times.
124381 if(diagonalMovement)
18464 {
18465 5817 skipstep=(skipstep+1)%6;
18466
18467
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 2872 times.
5817 if(skipstep%2==0) z3skip=1;
18468 2945 else z3skip=0;
18469
18470
2/2
✓ Branch 0 taken 3919 times.
✓ Branch 1 taken 1898 times.
5817 if(skipstep%3==0) z3diagskip=1;
18471 3919 else z3diagskip=0;
18472 5817 }
18473 else
18474 {
18475
2/2
✓ Branch 0 taken 79518 times.
✓ Branch 1 taken 39046 times.
118564 if(d2<left)
18476 {
18477
2/2
✓ Branch 0 taken 48027 times.
✓ Branch 1 taken 31491 times.
79518 if(ystep>1)
18478 {
18479 31491 skipstep^=1;
18480 31491 ystep=skipstep;
18481 31491 }
18482 79518 }
18483 else
18484 {
18485
2/2
✓ Branch 0 taken 23745 times.
✓ Branch 1 taken 15301 times.
39046 if(xstep>1)
18486 {
18487 15301 skipstep^=1;
18488 15301 xstep=skipstep;
18489 15301 }
18490 }
18491 }
18492 124381 }
18493 // else if(is_swimming || (slowcharging && slowcombo))
18494 else if(
18495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3232566 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3232677 (is_swimming && (zinit.hero_swim_speed<60))||
18496
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 3232455 times.
3232566 (slowcharging && slowcombo)
18497 )
18498 {
18499 //swimming, or charging on a slow combo, moves at 1/2 speed
18500 111 totalskip = !totalskip;
18501
18502
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
18503 {
18504 skipstep=0;
18505 }
18506 111 }
18507 else
18508 {
18509 3232455 totalskip = false;
18510
18511
2/2
✓ Branch 0 taken 2921432 times.
✓ Branch 1 taken 311023 times.
3232455 if(diagonalMovement)
18512 {
18513 311023 skipstep=0;
18514 311023 }
18515 }
18516
18517
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 3356891 times.
3356947 if(!totalskip)
18518 {
18519
2/2
✓ Branch 0 taken 316840 times.
✓ Branch 1 taken 3040051 times.
3356891 if(diagonalMovement)
18520 {
18521
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 42924 times.
✓ Branch 2 taken 28497 times.
✓ Branch 3 taken 134155 times.
✓ Branch 4 taken 111264 times.
316840 switch(d2)
18522 {
18523 case up:
18524
2/2
✓ Branch 0 taken 3502 times.
✓ Branch 1 taken 39422 times.
42924 if(shiftdir==left)
18525 {
18526
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 1264 times.
3502 if(walkable)
18527 {
18528 2238 dy-=1-z3diagskip;
18529 2238 dx-=1-z3diagskip;
18530 2238 z3step=2;
18531 2238 }
18532 else
18533 {
18534 1264 dx-=1-z3diagskip;
18535 1264 z3step=2;
18536 }
18537 3502 }
18538
2/2
✓ Branch 0 taken 4597 times.
✓ Branch 1 taken 34825 times.
39422 else if(shiftdir==right)
18539 {
18540
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 1732 times.
4597 if(walkable)
18541 {
18542 2865 dy-=1-z3diagskip;
18543 2865 dx+=1-z3diagskip;
18544 2865 z3step=2;
18545 2865 }
18546 else
18547 {
18548 1732 dx+=1-z3diagskip;
18549 1732 z3step=2;
18550 }
18551 4597 }
18552 else
18553 {
18554
2/2
✓ Branch 0 taken 16422 times.
✓ Branch 1 taken 18403 times.
34825 if(walkable)
18555 {
18556 18403 dy-=z3step-z3skip;
18557 18403 z3step=(z3step%2)+1;
18558 18403 }
18559 }
18560
18561 42924 break;
18562
18563 case down:
18564
2/2
✓ Branch 0 taken 3039 times.
✓ Branch 1 taken 25458 times.
28497 if(shiftdir==left)
18565 {
18566
2/2
✓ Branch 0 taken 1696 times.
✓ Branch 1 taken 1343 times.
3039 if(walkable)
18567 {
18568 1696 dy+=1-z3diagskip;
18569 1696 dx-=1-z3diagskip;
18570 1696 z3step=2;
18571 1696 }
18572 else
18573 {
18574 1343 dx-=1-z3diagskip;
18575 1343 z3step=2;
18576 }
18577 3039 }
18578
2/2
✓ Branch 0 taken 3600 times.
✓ Branch 1 taken 21858 times.
25458 else if(shiftdir==right)
18579 {
18580
2/2
✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 1112 times.
3600 if(walkable)
18581 {
18582 2488 dy+=1-z3diagskip;
18583 2488 dx+=1-z3diagskip;
18584 2488 z3step=2;
18585 2488 }
18586 else
18587 {
18588 1112 dx+=1-z3diagskip;
18589 1112 z3step=2;
18590 }
18591 3600 }
18592 else
18593 {
18594
2/2
✓ Branch 0 taken 9004 times.
✓ Branch 1 taken 12854 times.
21858 if(walkable)
18595 {
18596 12854 dy+=z3step-z3skip;
18597 12854 z3step=(z3step%2)+1;
18598 12854 }
18599 }
18600
18601 28497 break;
18602
18603 case right:
18604
2/2
✓ Branch 0 taken 129352 times.
✓ Branch 1 taken 4803 times.
134155 if(shiftdir==up)
18605 {
18606
2/2
✓ Branch 0 taken 4409 times.
✓ Branch 1 taken 394 times.
4803 if(walkable)
18607 {
18608 4409 dy-=1-z3diagskip;
18609 4409 dx+=1-z3diagskip;
18610 4409 z3step=2;
18611 4409 }
18612 else
18613 {
18614 394 dy-=1-z3diagskip;
18615 394 z3step=2;
18616 }
18617 4803 }
18618
2/2
✓ Branch 0 taken 3813 times.
✓ Branch 1 taken 125539 times.
129352 else if(shiftdir==down)
18619 {
18620
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 450 times.
3813 if(walkable)
18621 {
18622 3363 dy+=1-z3diagskip;
18623 3363 dx+=1-z3diagskip;
18624 3363 z3step=2;
18625 3363 }
18626 else
18627 {
18628 450 dy+=1-z3diagskip;
18629 450 z3step=2;
18630 }
18631 3813 }
18632 else
18633 {
18634
2/2
✓ Branch 0 taken 13252 times.
✓ Branch 1 taken 112287 times.
125539 if(walkable)
18635 {
18636 112287 dx+=z3step-z3skip;
18637 112287 z3step=(z3step%2)+1;
18638 112287 }
18639 }
18640
18641 134155 break;
18642
18643 case left:
18644
2/2
✓ Branch 0 taken 107496 times.
✓ Branch 1 taken 3768 times.
111264 if(shiftdir==up)
18645 {
18646
2/2
✓ Branch 0 taken 3458 times.
✓ Branch 1 taken 310 times.
3768 if(walkable)
18647 {
18648 3458 dy-=1-z3diagskip;
18649 3458 dx-=1-z3diagskip;
18650 3458 z3step=2;
18651 3458 }
18652 else
18653 {
18654 310 dy-=1-z3diagskip;
18655 310 z3step=2;
18656 }
18657 3768 }
18658
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 104392 times.
107496 else if(shiftdir==down)
18659 {
18660
2/2
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 281 times.
3104 if(walkable)
18661 {
18662 2823 dy+=1-z3diagskip;
18663 2823 dx-=1-z3diagskip;
18664 2823 z3step=2;
18665 2823 }
18666 else
18667 {
18668 281 dy+=1-z3diagskip;
18669 281 z3step=2;
18670 }
18671 3104 }
18672 else
18673 {
18674
2/2
✓ Branch 0 taken 12264 times.
✓ Branch 1 taken 92128 times.
104392 if(walkable)
18675 {
18676 92128 dx-=z3step-z3skip;
18677 92128 z3step=(z3step%2)+1;
18678 92128 }
18679 }
18680
18681 111264 break;
18682 }
18683 316840 }
18684 else
18685 {
18686
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 711802 times.
✓ Branch 2 taken 581791 times.
✓ Branch 3 taken 840179 times.
✓ Branch 4 taken 906279 times.
3040051 switch(d2)
18687 {
18688 case up:
18689
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 711494 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
711802 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
18690
18691 711802 break;
18692
18693 case down:
18694
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 581737 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
581791 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
18695
18696 581791 break;
18697
18698 case left:
18699 840179 dx-=xstep;
18700 840179 break;
18701
18702 case right:
18703 906279 dx+=xstep;
18704 906279 break;
18705 }
18706 }
18707 3356891 }
18708
18709
8/16
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3356361 times.
✓ Branch 2 taken 3356082 times.
✓ Branch 3 taken 865 times.
✓ Branch 4 taken 3355886 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 3355886 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3355886 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3356947 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
18710 {
18711 3355886 dir=d2;
18712 3355886 }
18713
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1061 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1061 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
18714 {
18715 dir = shiftdir;
18716 }
18717
18718
3/4
✓ Branch 0 taken 3310134 times.
✓ Branch 1 taken 46813 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3310134 times.
3356947 if(action != swimming && !IsSideSwim())
18719 {
18720 3310134 herostep();
18721
18722 //ack... don't walk if in midair! -DD
18723
12/14
✓ Branch 0 taken 3309548 times.
✓ Branch 1 taken 586 times.
✓ Branch 2 taken 3309269 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 3309109 times.
✓ Branch 5 taken 160 times.
✓ Branch 6 taken 3309109 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 149353 times.
✓ Branch 9 taken 3159756 times.
✓ Branch 10 taken 81755 times.
✓ Branch 11 taken 67598 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 81755 times.
3310134 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
18724 {
18725 3227354 action=walking; FFCore.setHeroAction(walking);
18726 3227354 }
18727
18728
2/2
✓ Branch 0 taken 3135977 times.
✓ Branch 1 taken 174157 times.
3310134 if(++hero_count > (16*hero_animation_speed))
18729 174157 hero_count=0;
18730 3310134 }
18731
2/2
✓ Branch 0 taken 23410 times.
✓ Branch 1 taken 23403 times.
46813 else if(!(frame & 1))
18732 {
18733 23403 herostep();
18734 23403 }
18735
18736
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3356361 times.
✓ Branch 2 taken 586 times.
✗ Branch 3 not taken.
3356947 if(charging==0 || attack!=wHammer)
18737 {
18738 3356947 sprite::move((zfix)dx,(zfix)dy);
18739 3356947 }
18740 3356947 }
18741 3437663 void HeroClass::moveOld2(int32_t d2, int32_t forceRate)
18742 {
18743
4/6
✓ Branch 0 taken 3437348 times.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 3437348 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3437348 times.
3437663 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
18744 315 return;
18745
18746
3/4
✓ Branch 0 taken 3356947 times.
✓ Branch 1 taken 80401 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3356947 times.
3437348 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
18747 {
18748 3356947 moveOld(d2);
18749 3356947 return;
18750 }
18751
18752
4/8
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 77425 times.
✓ Branch 2 taken 2976 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2976 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
157826 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
18753
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 77425 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
77425 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
18754 //!DIMITODO: add QR for slow combos under hero
18755
4/4
✓ Branch 0 taken 77425 times.
✓ Branch 1 taken 2976 times.
✓ Branch 2 taken 2976 times.
✓ Branch 3 taken 5952 times.
86353 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
18756 {
18757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5952 times.
5952 if(tmpscr2[i].valid!=0)
18758 {
18759
1/2
✓ Branch 0 taken 5952 times.
✗ Branch 1 not taken.
5952 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18760 {
18761
2/4
✓ Branch 0 taken 5952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5952 times.
✗ Branch 3 not taken.
5952 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
18762 {
18763 slowcombo = false;
18764 break;
18765 }
18766 5952 }
18767 else
18768 {
18769 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
18770 {
18771 slowcombo = false;
18772 break;
18773 }
18774 }
18775 5952 }
18776 8928 }
18777
1/2
✓ Branch 0 taken 80401 times.
✗ Branch 1 not taken.
80401 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
18778 80401 bool is_swimming = (action == swimming);
18779 80401 bool fastSwim = (zinit.hero_swim_speed>60);
18780 80401 zfix rate(steprate);
18781 80401 int32_t shieldid = getCurrentActiveShield();
18782
1/2
✓ Branch 0 taken 80401 times.
✗ Branch 1 not taken.
80401 if(shieldid > -1)
18783 {
18784 itemdata const& shield = itemsbuf[shieldid];
18785 if(shield.flags & ITEM_FLAG10) //Change Speed flag
18786 {
18787 zfix perc = shield.misc7;
18788 perc /= 100;
18789 if(perc < 0)
18790 perc = (perc*-1)+1;
18791 rate = (rate * perc) + shield.misc8;
18792 }
18793 }
18794
18795 80401 zfix dx, dy;
18796 80401 zfix movepix(rate / 100);
18797 80401 zfix step(movepix);
18798 80401 zfix step_diag(movepix);
18799 80401 zfix up_step(game->get_sideswim_up() / -100.0);
18800 80401 zfix left_step(game->get_sideswim_side() / -100.0);
18801 80401 zfix right_step(game->get_sideswim_side() / 100.0);
18802 80401 zfix down_step(game->get_sideswim_down() / 100.0);
18803 80401 bool checkladder = false;
18804
18805
2/2
✓ Branch 0 taken 80400 times.
✓ Branch 1 taken 1 times.
80401 if(hero_newstep > movepix) hero_newstep = movepix;
18806
2/2
✓ Branch 0 taken 80400 times.
✓ Branch 1 taken 1 times.
80401 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
18807 //2/3 speed
18808
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80401 times.
✓ Branch 2 taken 77425 times.
✓ Branch 3 taken 77425 times.
✓ Branch 4 taken 80401 times.
✓ Branch 5 taken 77425 times.
80401 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
18809 {
18810 157826 step = ((step / 3.0) * 2);
18811 157826 step_diag = ((step_diag / 3.0) * 2);
18812 157826 up_step = ((up_step / 3.0) * 2);
18813 157826 left_step = ((left_step / 3.0) * 2);
18814 157826 right_step = ((right_step / 3.0) * 2);
18815 157826 down_step = ((down_step / 3.0) * 2);
18816 157826 }
18817 //1/2 speed
18818
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 77425 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 77425 times.
77425 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
18819 {
18820 step /= 2;
18821 step_diag /= 2;
18822 up_step /= 2;
18823 left_step /= 2;
18824 right_step /= 2;
18825 down_step /= 2;
18826 }
18827 //normal speed
18828 else
18829 {
18830 //no modification
18831 }
18832
18833
1/2
✓ Branch 0 taken 80401 times.
✗ Branch 1 not taken.
80401 if(diagonalMovement)
18834 {
18835 //zprint2("Player's X is %d, Y is %d\n", x, y);
18836
6/6
✓ Branch 0 taken 63563 times.
✓ Branch 1 taken 16838 times.
✓ Branch 2 taken 66216 times.
✓ Branch 3 taken 3255 times.
✓ Branch 4 taken 29265 times.
✓ Branch 5 taken 53789 times.
122383 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
18837
4/4
✓ Branch 0 taken 49878 times.
✓ Branch 1 taken 46623 times.
✓ Branch 2 taken 4903 times.
✓ Branch 3 taken 44975 times.
3255 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
18838 {
18839
2/4
✓ Branch 0 taken 17458 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17458 times.
125036 if(hero_newstep > 0 && hero_newstep_diag > 0)
18840 {
18841 17458 step = STEP_DIAGONAL(step);
18842 17458 step_diag = STEP_DIAGONAL(step_diag);
18843 17458 up_step = STEP_DIAGONAL(up_step);
18844 17458 left_step = STEP_DIAGONAL(left_step);
18845 17458 right_step = STEP_DIAGONAL(right_step);
18846 17458 down_step = STEP_DIAGONAL(down_step);
18847 17458 }
18848 17458 }
18849
2/2
✓ Branch 0 taken 56233 times.
✓ Branch 1 taken 6200 times.
62433 if(hero_newstep < step) step = hero_newstep; //handle collision
18850
2/2
✓ Branch 0 taken 59830 times.
✓ Branch 1 taken 2603 times.
62433 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
18851
5/5
✓ Branch 0 taken 17968 times.
✓ Branch 1 taken 16838 times.
✓ Branch 2 taken 16349 times.
✓ Branch 3 taken 22786 times.
✓ Branch 4 taken 24428 times.
62433 switch(d2)
18852 {
18853 case up:
18854
3/3
✓ Branch 0 taken 13388 times.
✓ Branch 1 taken 1761 times.
✓ Branch 2 taken 1689 times.
16838 switch(shiftdir)
18855 {
18856 case left:
18857 1761 dx = -step_diag;
18858
1/2
✓ Branch 0 taken 1761 times.
✗ Branch 1 not taken.
1761 if (IsSideSwim()) dx = left_step;
18859 1761 break;
18860 case right:
18861 1689 dx = step_diag;
18862
1/2
✓ Branch 0 taken 1689 times.
✗ Branch 1 not taken.
1689 if (IsSideSwim()) dx = right_step;
18863 1689 break;
18864 }
18865
2/2
✓ Branch 0 taken 2320 times.
✓ Branch 1 taken 14518 times.
16838 if(walkable)
18866 {
18867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14518 times.
14518 if (!IsSideSwim()) dy = -step;
18868
1/2
✓ Branch 0 taken 14518 times.
✗ Branch 1 not taken.
14518 if (IsSideSwim())
18869 {
18870 dy = up_step;
18871 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
18872 }
18873 14518 }
18874 16838 break;
18875 case down:
18876
3/3
✓ Branch 0 taken 12062 times.
✓ Branch 1 taken 2161 times.
✓ Branch 2 taken 2126 times.
16349 switch(shiftdir)
18877 {
18878 case left:
18879 2161 dx = -step_diag;
18880
1/2
✓ Branch 0 taken 2161 times.
✗ Branch 1 not taken.
2161 if (IsSideSwim()) dx = left_step;
18881 2161 break;
18882 case right:
18883 2126 dx = step_diag;
18884
1/2
✓ Branch 0 taken 2126 times.
✗ Branch 1 not taken.
2126 if (IsSideSwim()) dx = right_step;
18885 2126 break;
18886 }
18887
2/2
✓ Branch 0 taken 1611 times.
✓ Branch 1 taken 14738 times.
16349 if(walkable)
18888 {
18889 14738 dy = step;
18890
1/2
✓ Branch 0 taken 14738 times.
✗ Branch 1 not taken.
14738 if (IsSideSwim()) dy = down_step;
18891 14738 }
18892 16349 break;
18893 case left:
18894
3/3
✓ Branch 0 taken 17935 times.
✓ Branch 1 taken 2703 times.
✓ Branch 2 taken 2148 times.
22786 switch(shiftdir)
18895 {
18896 case up:
18897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2703 times.
2703 if (!IsSideSwim()) dy = -step_diag;
18898
1/2
✓ Branch 0 taken 2703 times.
✗ Branch 1 not taken.
2703 if (IsSideSwim())
18899 {
18900 dy = up_step;
18901 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
18902 }
18903 2703 break;
18904 case down:
18905 2148 dy = step_diag;
18906
1/2
✓ Branch 0 taken 2148 times.
✗ Branch 1 not taken.
2148 if (IsSideSwim()) dy = down_step;
18907 2148 break;
18908 }
18909
2/2
✓ Branch 0 taken 2405 times.
✓ Branch 1 taken 20381 times.
22786 if(walkable)
18910 {
18911 20381 dx = -step;
18912
1/2
✓ Branch 0 taken 20381 times.
✗ Branch 1 not taken.
20381 if (IsSideSwim()) dx = left_step;
18913 20381 }
18914 22786 break;
18915 case right:
18916
3/3
✓ Branch 0 taken 19558 times.
✓ Branch 1 taken 2529 times.
✓ Branch 2 taken 2341 times.
24428 switch(shiftdir)
18917 {
18918 case up:
18919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2529 times.
2529 if (!IsSideSwim()) dy = -step_diag;
18920
1/2
✓ Branch 0 taken 2529 times.
✗ Branch 1 not taken.
2529 if (IsSideSwim())
18921 {
18922 dy = up_step;
18923 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
18924 }
18925 2529 break;
18926 case down:
18927 2341 dy = step_diag;
18928
1/2
✓ Branch 0 taken 2341 times.
✗ Branch 1 not taken.
2341 if (IsSideSwim()) dy = down_step;
18929 2341 break;
18930 }
18931
2/2
✓ Branch 0 taken 2418 times.
✓ Branch 1 taken 22010 times.
24428 if(walkable)
18932 {
18933 22010 dx = step;
18934
1/2
✓ Branch 0 taken 22010 times.
✗ Branch 1 not taken.
22010 if (IsSideSwim()) dx = right_step;
18935 22010 }
18936 24428 break;
18937 };
18938 98369 }
18939 else
18940 {
18941 if(hero_newstep < step) step = hero_newstep; //handle collision
18942 switch(d2)
18943 {
18944 case up:
18945 dy -= step;
18946 if (IsSideSwim()) dy = up_step;
18947 break;
18948 case down:
18949 dy += step;
18950 if (IsSideSwim()) dy = down_step;
18951 break;
18952 case left:
18953 dx -= step;
18954 if (IsSideSwim()) dx = left_step;
18955 break;
18956 case right:
18957 dx += step;
18958 if (IsSideSwim()) dx = right_step;
18959 break;
18960 };
18961 }
18962 98369 hero_newstep = movepix;
18963 98369 hero_newstep_diag = movepix;
18964
18965
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 98369 times.
✓ Branch 2 taken 80401 times.
✓ Branch 3 taken 17968 times.
✓ Branch 4 taken 80401 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 80401 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 80401 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
98369 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
18966 {
18967 80401 dir=d2;
18968 80401 }
18969
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 17968 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
17968 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
18970 {
18971 dir = shiftdir;
18972 }
18973
2/2
✓ Branch 0 taken 98357 times.
✓ Branch 1 taken 12 times.
98369 if(forceRate > -1)
18974 {
18975 12 checkladder = false;
18976
1/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12 switch(dir)
18977 {
18978 case right:
18979 case r_up:
18980 case r_down:
18981 12 dx = zfix(forceRate) / 100;
18982 12 break;
18983 case left:
18984 case l_up:
18985 case l_down:
18986 dx = zfix(-forceRate) / 100;
18987 break;
18988 default:
18989 dx = 0;
18990 }
18991
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
12 switch(dir)
18992 {
18993 case down:
18994 case r_down:
18995 case l_down:
18996 dy = zfix(forceRate) / 100;
18997 break;
18998 case up:
18999 case r_up:
19000 case l_up:
19001 dy = zfix(-forceRate) / 100;
19002 break;
19003 default:
19004 12 dy = 0;
19005 12 }
19006 12 }
19007
4/4
✓ Branch 0 taken 30273 times.
✓ Branch 1 taken 68096 times.
✓ Branch 2 taken 24061 times.
✓ Branch 3 taken 6212 times.
98369 if(dx == 0 && dy == 0) return;
19008
5/8
✓ Branch 0 taken 74189 times.
✓ Branch 1 taken 17968 times.
✓ Branch 2 taken 74189 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74189 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 74189 times.
92157 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
19009 {
19010 74189 herostep();
19011
19012 //ack... don't walk if in midair! -DD
19013
5/14
✓ Branch 0 taken 74189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74189 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74189 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74189 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 74189 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
74189 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
19014 {
19015 74189 action=walking; FFCore.setHeroAction(walking);
19016 74189 }
19017
19018
2/2
✓ Branch 0 taken 70396 times.
✓ Branch 1 taken 3793 times.
74189 if(++hero_count > (16*hero_animation_speed))
19019 3793 hero_count=0;
19020 74189 }
19021
1/2
✓ Branch 0 taken 17968 times.
✗ Branch 1 not taken.
17968 else if(!(frame & 1))
19022 {
19023 herostep();
19024 }
19025
19026
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 92157 times.
✓ Branch 2 taken 17968 times.
✓ Branch 3 taken 17968 times.
92157 if(charging==0 || attack!=wHammer)
19027 {
19028 110125 sprite::move(dx, dy);
19029 110125 WalkflagInfo info;
19030 110125 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
19031 110125 execute(info);
19032
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 74189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 74189 times.
✗ Branch 7 not taken.
110125 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
19033 {
19034 if (game->get_sideswim_jump() != 0)
19035 {
19036 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
19037 sfx(WAV_ZN1SPLASH,(int32_t)x);
19038 hopclk = 0;
19039 if (charging || spins) action = attacking;
19040 else action = none;
19041 }
19042 else
19043 {
19044 sprite::move(zfix(0), zfix(-1*dy));
19045 }
19046 }
19047 74189 }
19048 3455631 }
19049
19050 15690613 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
19051 {
19052 15690613 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
19053 }
19054 15690613 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
19055 {
19056 15690613 WalkflagInfo ret;
19057
19058 15690613 wx = vbound(wx, -1, 256);
19059 15690613 wy = vbound(wy, -1, 176);
19060
19061
8/8
✓ Branch 0 taken 15622371 times.
✓ Branch 1 taken 68242 times.
✓ Branch 2 taken 15558161 times.
✓ Branch 3 taken 64210 times.
✓ Branch 4 taken 15558130 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 2429 times.
✓ Branch 7 taken 15555701 times.
15690613 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
19062 {
19063 134912 ret.setUnwalkable(false);
19064 134912 return ret;
19065 }
19066
19067
2/2
✓ Branch 0 taken 41482 times.
✓ Branch 1 taken 15514219 times.
15555701 if(toogam)
19068 {
19069 41482 ret.setUnwalkable(false);
19070 41482 return ret;
19071 }
19072
19073
4/4
✓ Branch 0 taken 319804 times.
✓ Branch 1 taken 15194415 times.
✓ Branch 2 taken 312628 times.
✓ Branch 3 taken 7176 times.
15514219 if(blockpath && wy<(bigHitbox?80:88))
19074 {
19075 7176 ret.setUnwalkable(true);
19076 7176 return ret;
19077 }
19078
19079
4/4
✓ Branch 0 taken 133900 times.
✓ Branch 1 taken 15373143 times.
✓ Branch 2 taken 101869 times.
✓ Branch 3 taken 32031 times.
15507043 if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
19080 {
19081 32031 ret.setUnwalkable(true);
19082 32031 return ret;
19083 }
19084
19085
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 15474903 times.
15475012 if (collide_object(wx, wy,1, 1))
19086 {
19087 109 ret.setUnwalkable(true);
19088 109 return ret;
19089 }
19090
19091
15/22
✓ Branch 0 taken 9040628 times.
✓ Branch 1 taken 6434275 times.
✓ Branch 2 taken 8719751 times.
✓ Branch 3 taken 320877 times.
✓ Branch 4 taken 8434522 times.
✓ Branch 5 taken 285229 times.
✓ Branch 6 taken 285229 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 285229 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 285229 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 145354 times.
✓ Branch 15 taken 139875 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 139875 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 139875 times.
✓ Branch 20 taken 23842 times.
✓ Branch 21 taken 15451061 times.
15639515 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
19092
2/2
✓ Branch 0 taken 19258 times.
✓ Branch 1 taken 120617 times.
285229 && !get_bit(quest_rules,qr_FREEFORM))
19093 {
19094 23842 ret.setUnwalkable(true);
19095 23842 return ret;
19096 }
19097
19098
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15451061 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15451061 times.
15451061 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
19099
19100
6/6
✓ Branch 0 taken 9016786 times.
✓ Branch 1 taken 6434275 times.
✓ Branch 2 taken 8695909 times.
✓ Branch 3 taken 320877 times.
✓ Branch 4 taken 2475524 times.
✓ Branch 5 taken 6220385 times.
15451061 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
19101 {
19102
3/6
✓ Branch 0 taken 6220385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6220385 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6220385 times.
6220385 if((diagonalMovement||NO_GRIDLOCK))
19103 {
19104 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
19105
19106 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
19107 }
19108 6220385 }
19109 //All problems related to exiting water are probably here. -Z
19110
3/4
✓ Branch 0 taken 15109128 times.
✓ Branch 1 taken 341933 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15109128 times.
15451061 if(action==swimming || IsSideSwim())
19111 {
19112
2/2
✓ Branch 0 taken 325082 times.
✓ Branch 1 taken 16851 times.
341933 if(!wf)
19113 {
19114 16851 bool isthissolid = false;
19115
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16851 times.
✓ Branch 2 taken 16851 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4526 times.
✓ Branch 5 taken 12325 times.
21377 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
19116
4/6
✓ Branch 0 taken 12325 times.
✓ Branch 1 taken 4526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4526 times.
✓ Branch 4 taken 4526 times.
✗ Branch 5 not taken.
16851 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
19117
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4526 times.
✓ Branch 4 taken 4526 times.
✗ Branch 5 not taken.
4526 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
19118
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4526 times.
✓ Branch 4 taken 4526 times.
✗ Branch 5 not taken.
16851 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
19119 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
19120
19121
19122
5/6
✓ Branch 0 taken 6945 times.
✓ Branch 1 taken 9906 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6945 times.
✓ Branch 4 taken 9438 times.
✓ Branch 5 taken 26275 times.
26757 if(landswim>= (get_bit(quest_rules,qr_DROWN) && isSwimming() ? 1
19123
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 9398 times.
9906 : (!diagonalMovement) ? 1 : (get_bit(quest_rules,qr_NO_HOPPING)?1:22)))
19124 {
19125 //Check for out of bounds for swimming
19126 9438 bool changehop = true;
19127
19128
5/6
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 8533 times.
✓ Branch 2 taken 905 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8526 times.
✓ Branch 5 taken 7621 times.
9438 if((diagonalMovement||NO_GRIDLOCK))
19129 {
19130
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
17059 if(wx<0||wy<0)
19131 changehop = false;
19132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 else if(wx>248)
19133 changehop = false;
19134
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 else if(wx>240&&cnt==2)
19135 changehop = false;
19136
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 else if(wy>168)
19137 changehop = false;
19138 7 }
19139
3/4
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 6716 times.
✓ Branch 2 taken 7628 times.
✗ Branch 3 not taken.
7628 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
19140 //This may be where the hang-up for exiting water exists. -Z
19141 // hop out of the water
19142
2/2
✓ Branch 0 taken 6716 times.
✓ Branch 1 taken 912 times.
7628 if(changehop)
19143 912 ret.setHopClk(1);
19144 7628 }
19145 else
19146 {
19147
6/6
✓ Branch 0 taken 11799 times.
✓ Branch 1 taken 14476 times.
✓ Branch 2 taken 13902 times.
✓ Branch 3 taken 12373 times.
✓ Branch 4 taken 8268 times.
✓ Branch 5 taken 5634 times.
26275 if((!(get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
19148 {
19149 //int32_t vx=((int32_t)x+4)&0xFFF8;
19150 //int32_t vy=((int32_t)y+4)&0xFFF8;
19151
2/2
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 3015 times.
13902 if(d2==left)
19152 {
19153
4/4
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 468 times.
✓ Branch 3 taken 83 times.
1019 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
19154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
468 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
19155
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 468 times.
468 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
19156
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
468 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
19157 {
19158 468 ret.setHopDir(d2);
19159 468 ret.setIlswim(true);
19160 468 }
19161 83 else ret.setIlswim(false);
19162 551 }
19163
2/2
✓ Branch 0 taken 2200 times.
✓ Branch 1 taken 815 times.
3015 else if(d2==right)
19164 {
19165
4/4
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 1598 times.
✓ Branch 2 taken 602 times.
✓ Branch 3 taken 1598 times.
2802 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
19166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 602 times.
602 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
19167
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 602 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 602 times.
602 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
19168
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 602 times.
602 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
19169 {
19170 602 ret.setHopDir(d2);
19171 602 ret.setIlswim(true);
19172 602 }
19173 1598 else ret.setIlswim(false);
19174 2200 }
19175
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 349 times.
815 else if(d2==up)
19176 {
19177
4/4
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 93 times.
607 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
19178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 258 times.
258 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
19179
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 258 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 256 times.
258 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
19180
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
19181 {
19182 256 ret.setHopDir(d2);
19183 256 ret.setIlswim(true);
19184 256 }
19185 93 else ret.setIlswim(false);
19186 349 }
19187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 else if(d2==down)
19188 {
19189
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 270 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 270 times.
662 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
19190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
19191
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 196 times.
196 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
19192
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
196 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
19193 {
19194 196 ret.setHopDir(d2);
19195 196 ret.setIlswim(true);
19196 196 }
19197 270 else ret.setIlswim(false);
19198 466 }
19199 3566 }
19200
19201
2/4
✓ Branch 0 taken 15939 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15939 times.
15939 if(wx<0||wy<0);
19202
2/2
✓ Branch 0 taken 2246 times.
✓ Branch 1 taken 13693 times.
15939 else if(wx>248);
19203
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13693 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13693 else if(wx>240&&cnt==2);
19204
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 13352 times.
13693 else if(wy>168);
19205
3/4
✓ Branch 0 taken 6106 times.
✓ Branch 1 taken 7246 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6106 times.
13352 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
19206 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
19207
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 7228 times.
7246 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
19208 {
19209 18 ret.setUnwalkable(false);
19210 18 return ret;
19211 }
19212 else
19213 {
19214 7228 ret.setUnwalkable(true);
19215 7228 return ret;
19216 }
19217 }
19218 16321 }
19219 else
19220 {
19221 325082 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
19222 325082 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
19223
19224
8/8
✓ Branch 0 taken 300985 times.
✓ Branch 1 taken 24097 times.
✓ Branch 2 taken 270393 times.
✓ Branch 3 taken 30592 times.
✓ Branch 4 taken 24097 times.
✓ Branch 5 taken 30592 times.
✓ Branch 6 taken 17008 times.
✓ Branch 7 taken 7089 times.
325082 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
19225 {
19226 287401 ret.setUnwalkable(false);
19227 287401 return ret;
19228 }
19229 }
19230 54002 }
19231
2/2
✓ Branch 0 taken 255754 times.
✓ Branch 1 taken 14853374 times.
15109128 else if(ladderx+laddery) // ladder is being used
19232 {
19233
7/10
✓ Branch 0 taken 6010 times.
✓ Branch 1 taken 249744 times.
✓ Branch 2 taken 5957 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
255754 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
19234
7/10
✓ Branch 0 taken 6010 times.
✓ Branch 1 taken 249744 times.
✓ Branch 2 taken 5957 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
255754 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
19235
19236
4/6
✓ Branch 0 taken 255605 times.
✓ Branch 1 taken 149 times.
✓ Branch 2 taken 255605 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 255605 times.
255754 if((diagonalMovement||NO_GRIDLOCK))
19237 {
19238
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(ladderdir==up)
19239 {
19240 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
19241 {
19242 bool temp = false;
19243
19244 if(!(abs(lx-(ladderx+8))<=8))
19245 temp = true;
19246
19247 if(cnt==2)
19248 if(!(abs((lx+8)-(ladderx+8))<=8))
19249 temp=true;
19250
19251 if(!temp)
19252 {
19253 ret.setUnwalkable(false);
19254 return ret;
19255 }
19256
19257 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
19258 {
19259 ret.setUnwalkable(true);
19260 return ret;
19261 }
19262 }
19263 }
19264 else
19265 {
19266
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 71 times.
149 if(abs(lx-(ladderx+8))<=8)
19267 {
19268
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 49 times.
71 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
19269 {
19270 22 ret.setUnwalkable(false);
19271 22 return ret;
19272 }
19273
19274
5/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
49 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
19275 {
19276 13 ret.setUnwalkable(true);
19277 13 return ret;
19278 }
19279
19280
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
36 if((abs(ly-laddery+8)<=8) && d2<=down)
19281 {
19282 ret.setUnwalkable(false);
19283 return ret;
19284 }
19285 36 }
19286 }
19287 114 } // diagonalMovement
19288 else
19289 {
19290
2/2
✓ Branch 0 taken 152207 times.
✓ Branch 1 taken 103398 times.
255605 if((d2&2)==ladderdir) // same direction
19291 {
19292
3/3
✓ Branch 0 taken 8984 times.
✓ Branch 1 taken 135045 times.
✓ Branch 2 taken 8178 times.
152207 switch(d2)
19293 {
19294 case up:
19295
2/2
✓ Branch 0 taken 5684 times.
✓ Branch 1 taken 2494 times.
8178 if(y.getInt()<=laddery)
19296 {
19297
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5684 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5684 times.
✓ Branch 4 taken 432 times.
✓ Branch 5 taken 5252 times.
10936 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
19298
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5252 times.
✓ Branch 2 taken 5252 times.
✗ Branch 3 not taken.
5252 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
19299 5684 return ret;
19300
19301 }
19302
19303 [[fallthrough]];
19304 case down:
19305
2/2
✓ Branch 0 taken 6138 times.
✓ Branch 1 taken 5340 times.
11478 if((wy&0xF0)==laddery)
19306 {
19307 6138 ret.setUnwalkable(false);
19308 6138 return ret;
19309 }
19310
19311 5340 break;
19312
19313 default:
19314
2/2
✓ Branch 0 taken 53843 times.
✓ Branch 1 taken 81202 times.
135045 if((wx&0xF0)==ladderx)
19315 {
19316 53843 ret.setUnwalkable(false);
19317 53843 return ret;
19318 }
19319 81202 }
19320
19321
2/2
✓ Branch 0 taken 5340 times.
✓ Branch 1 taken 81202 times.
86542 if(d2<=down)
19322 {
19323
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5340 times.
✓ Branch 2 taken 5340 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 593 times.
✓ Branch 5 taken 4747 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4747 times.
✓ Branch 8 taken 4747 times.
✗ Branch 9 not taken.
5340 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
19324 5340 return ret;
19325 }
19326
19327
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 81202 times.
✓ Branch 2 taken 81202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14606 times.
✓ Branch 5 taken 66596 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 66596 times.
✓ Branch 8 taken 66596 times.
✗ Branch 9 not taken.
81202 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
19328 81202 return ret;
19329 }
19330
19331 // different dir
19332
3/8
✓ Branch 0 taken 102969 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102969 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
103398 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
19333 {
19334 102969 ret.setUnwalkable(true);
19335 102969 return ret;
19336 }
19337
19338
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
19339 {
19340 20 ret.setUnwalkable(false);
19341 20 return ret;
19342 }
19343 }
19344 523 }
19345
6/6
✓ Branch 0 taken 12285482 times.
✓ Branch 1 taken 2567892 times.
✓ Branch 2 taken 11982737 times.
✓ Branch 3 taken 302745 times.
✓ Branch 4 taken 1447445 times.
✓ Branch 5 taken 10535292 times.
14853374 else if(wf || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
19346 {
19347 // see if it's a good spot for the ladder or for swimming
19348
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4318082 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4318082 times.
4318082 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
19349
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4318082 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4318082 times.
4318082 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
19350
19351
2/2
✓ Branch 0 taken 2267639 times.
✓ Branch 1 taken 2050443 times.
4318082 if(get_bit(quest_rules, qr_DROWN))
19352 {
19353 // Drowning changes the following attributes:
19354 // * Dangerous water is also walkable, so ignore the previous
19355 // definitions of unwalkablex and unwalkablex8.
19356 // * Instead, prevent the ladder from being used in the
19357 // one frame where Hero has landed on water before drowning.
19358 2267639 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
19359 2267639 }
19360
19361 // check if he can swim
19362
5/6
✓ Branch 0 taken 1330235 times.
✓ Branch 1 taken 2987847 times.
✓ Branch 2 taken 1330019 times.
✓ Branch 3 taken 216 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1330019 times.
4318082 if(current_item(itype_flippers) && z==0 && fakez==0)
19363 {
19364 1330019 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
19365 1330019 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
19366
2/6
✓ Branch 0 taken 1330019 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1330019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1330019 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
19367 {
19368 //ladder ignores water combos that are now walkable thanks to flippers -DD
19369
2/2
✓ Branch 0 taken 5037 times.
✓ Branch 1 taken 1324982 times.
1330019 unwalkablex = unwalkablex && (!wtrx);
19370
2/2
✓ Branch 0 taken 574392 times.
✓ Branch 1 taken 755627 times.
1330019 unwalkablex8 = unwalkablex8 && (!wtrx8);
19371
19372
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1330015 times.
1330019 if(landswim >= 22)
19373 {
19374 4 ret.setHopClk(2);
19375 4 ret.setUnwalkable(false);
19376 4 return ret;
19377 }
19378
8/8
✓ Branch 0 taken 1173940 times.
✓ Branch 1 taken 156075 times.
✓ Branch 2 taken 6535 times.
✓ Branch 3 taken 1167405 times.
✓ Branch 4 taken 156075 times.
✓ Branch 5 taken 1167405 times.
✓ Branch 6 taken 873 times.
✓ Branch 7 taken 155202 times.
1330015 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
19379 {
19380
4/6
✓ Branch 0 taken 5986 times.
✓ Branch 1 taken 1422 times.
✓ Branch 2 taken 5986 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5986 times.
7408 if(!(diagonalMovement||NO_GRIDLOCK))
19381 {
19382 5986 ret.setHopClk(2);
19383
19384
2/4
✓ Branch 0 taken 5986 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5986 times.
5986 if(charging || spins>5)
19385 {
19386 //if Hero is charging, he might be facing the wrong direction (we want him to
19387 //hop into the water, not in the facing direction)
19388 ret.setDir(d2);
19389 //moreover Hero can't charge in the water -DD
19390 ret.setChargeAttack();
19391 }
19392
19393 5986 ret.setUnwalkable(false);
19394 5986 return ret;
19395 }
19396
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 1245 times.
1422 else if(dir==d2)
19397 {
19398 1245 ret.setIlswim(true);
19399 1245 ladderx = 0;
19400 1245 laddery = 0;
19401 1245 }
19402 1422 }
19403 1324029 }
19404 1324029 }
19405
19406 // check if he can use the ladder
19407 // "Allow Ladder Anywhere" is toggled by fLADDER
19408
2/2
✓ Branch 0 taken 2983096 times.
✓ Branch 1 taken 1328996 times.
4312092 if(can_deploy_ladder())
19409 // laddersetup
19410 {
19411 // Check if there's water to use the ladder over
19412 1328996 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
19413 1328996 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
19414 1328996 int32_t ldrid = current_item_id(itype_ladder);
19415
1/2
✓ Branch 0 taken 1328996 times.
✗ Branch 1 not taken.
1328996 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
19416
19417
4/4
✓ Branch 0 taken 1321505 times.
✓ Branch 1 taken 7491 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 1321485 times.
1328996 if(wtrx || wtrx8)
19418 {
19419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7511 times.
7511 if(isSideViewHero())
19420 {
19421 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
19422 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
19423 }
19424 // * walk on half-water using the ladder instead of using flippers.
19425 // * otherwise, walk on ladder(+hookshot) combos.
19426
3/8
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 7085 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 426 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7511 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
19427 {
19428
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 387 times.
426 if(!get_bit(quest_rules, qr_OLD_210_WATER))
19429 {
19430 //if Hero could swim on a tile instead of using the ladder,
19431 //refuse to use the ladder to step over that tile. -DD
19432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
19433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
19434 387 }
19435 426 }
19436 7511 }
19437 else
19438 {
19439 // No water; check other things
19440
19441 //Check pits
19442
2/2
✓ Branch 0 taken 1320458 times.
✓ Branch 1 taken 1027 times.
1321485 if(ladderpits)
19443 {
19444 1027 int32_t pit_cmb = getpitfall(wx,wy);
19445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
19446 1027 pit_cmb = getpitfall(x+8,wy);
19447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
19448 1027 }
19449
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1320458 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
1321485 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
19450 {
19451 1321485 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
19452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1321485 times.
1321485 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
19453 1321485 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
19454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1321485 times.
1321485 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
19455 1321485 }
19456 }
19457
19458
2/2
✓ Branch 0 taken 2657992 times.
✓ Branch 1 taken 1328996 times.
3986988 for (int32_t i = 0; i <= 1; ++i)
19459 {
19460
2/2
✓ Branch 0 taken 2273662 times.
✓ Branch 1 taken 384330 times.
2657992 if(tmpscr2[i].valid!=0)
19461 {
19462
2/2
✓ Branch 0 taken 319092 times.
✓ Branch 1 taken 65238 times.
384330 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19463 {
19464
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 319092 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
319092 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
19465
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 319092 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
319092 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
19466 319092 }
19467 else
19468 {
19469
3/4
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 64979 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
65238 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
19470
3/4
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 65001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 237 times.
65238 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
19471 }
19472 384330 }
19473 2657992 }
19474
2/2
✓ Branch 0 taken 180430 times.
✓ Branch 1 taken 1148566 times.
1328996 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
19475
19476
4/6
✓ Branch 0 taken 1288526 times.
✓ Branch 1 taken 40470 times.
✓ Branch 2 taken 1288526 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1288526 times.
1328996 if((diagonalMovement||NO_GRIDLOCK))
19477 {
19478
2/2
✓ Branch 0 taken 11725 times.
✓ Branch 1 taken 28745 times.
40470 if(d2==dir)
19479 {
19480 28745 int32_t c = walkwater ? 0:8;
19481 28745 int32_t b = walkwater ? 8:0;
19482
19483
2/2
✓ Branch 0 taken 21217 times.
✓ Branch 1 taken 7528 times.
28745 if(d2>=left)
19484 {
19485 // If the difference between wy and y is small enough
19486
4/4
✓ Branch 0 taken 6210 times.
✓ Branch 1 taken 15007 times.
✓ Branch 2 taken 21214 times.
✓ Branch 3 taken 3 times.
21217 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
19487 {
19488 // Don't activate the ladder if it would be entirely
19489 // over water and Hero has the flippers. This isn't
19490 // a good way to do this, but it's too risky
19491 // to make big changes to this stuff.
19492 3 bool deployLadder=true;
19493 3 int32_t lx=wx&0xF0;
19494
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
3 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
19495 {
19496
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
19497 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
19498 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
19499 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
19500 deployLadder=false;
19501 2 }
19502
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(deployLadder)
19503 {
19504 3 ladderx = wx&0xF0;
19505 3 laddery = y;
19506 3 ladderdir = left;
19507 3 ladderstart = d2;
19508 3 ret.setUnwalkable(laddery!=y.getInt());
19509 3 return ret;
19510 }
19511 }
19512 21214 }
19513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7528 times.
7528 else if(d2<=down)
19514 {
19515 // If the difference between wx and x is small enough
19516
3/4
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 4705 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7528 times.
7528 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
19517 {
19518 ladderx = x;
19519 laddery = wy&0xF0;
19520 ladderdir = up;
19521 ladderstart = d2;
19522 ret.setUnwalkable(ladderx!=x.getInt());
19523 return ret;
19524 }
19525
19526
2/2
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 4705 times.
7528 if(cnt==2)
19527 {
19528
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4705 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4705 times.
4705 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
19529 {
19530 ladderx = x;
19531 laddery = wy&0xF0;
19532 ladderdir = up;
19533 ladderstart = d2;
19534 ret.setUnwalkable(ladderx!=x.getInt());
19535 return ret;
19536 }
19537 4705 }
19538 7528 }
19539 28742 }
19540 40467 }
19541 else
19542 {
19543
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1288526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1288526 times.
✓ Branch 4 taken 110191 times.
✓ Branch 5 taken 1178335 times.
1288526 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
19544
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1288526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1288526 times.
✓ Branch 4 taken 1205515 times.
✓ Branch 5 taken 83011 times.
1288526 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
19545
19546
2/2
✓ Branch 0 taken 1188054 times.
✓ Branch 1 taken 100472 times.
1288562 if((d2>=left && wtrx)
19547 // Deploy the ladder vertically even if Hero is only half on water.
19548
8/8
✓ Branch 0 taken 12556 times.
✓ Branch 1 taken 1175498 times.
✓ Branch 2 taken 100472 times.
✓ Branch 3 taken 1175498 times.
✓ Branch 4 taken 822 times.
✓ Branch 5 taken 99650 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 100436 times.
1288526 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
19549 {
19550
4/4
✓ Branch 0 taken 12202 times.
✓ Branch 1 taken 354 times.
✓ Branch 2 taken 501 times.
✓ Branch 3 taken 11701 times.
12556 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
19551 855 ladderdir = up;
19552 else
19553 11701 ladderdir = left;
19554
19555
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 11701 times.
12556 if(ladderdir==up)
19556 {
19557 855 ladderx = x.getInt()&0xF8;
19558 855 laddery = wy&0xF0;
19559 855 }
19560 else
19561 {
19562 11701 ladderx = wx&0xF0;
19563 11701 laddery = y.getInt()&0xF8;
19564 }
19565
19566 12556 ret.setUnwalkable(false);
19567 12556 return ret;
19568 }
19569 }
19570 1316437 }
19571 4299533 }
19572
19573 14889350 ret.setUnwalkable(wf);
19574 14889350 return ret;
19575 15697329 }
19576
19577 // Only checks for moving blocks. Apparently this is a thing we need.
19578 1483883 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
19579 {
19580 1483883 HeroClass::WalkflagInfo ret;
19581
2/2
✓ Branch 0 taken 15089 times.
✓ Branch 1 taken 1468794 times.
1483883 if (!blockmoving) //Without this, weird swimming behaviors happen.
19582 {
19583 1468794 ret.setFlags(~1);
19584 1468794 ret.setHopDir(-1);
19585 1468794 }
19586
2/2
✓ Branch 0 taken 2636 times.
✓ Branch 1 taken 1481247 times.
1483883 if(toogam) return ret;
19587
2/2
✓ Branch 0 taken 1466158 times.
✓ Branch 1 taken 15089 times.
1481247 if (blockmoving)
19588 15089 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
19589
1/2
✓ Branch 0 taken 1481247 times.
✗ Branch 1 not taken.
1481247 if (collide_object(wx, wy,1, 1))
19590 ret.setUnwalkable(true);
19591 1481247 return ret;
19592 1483883 }
19593
19594 6263211 bool HeroClass::checksoliddamage()
19595 {
19596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6263211 times.
6263211 if(toogam) return false;
19597
19598
2/4
✓ Branch 0 taken 6263211 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6263211 times.
6263211 if(z!=0||fakez!=0) return false;
19599 6263211 int32_t bx = x.getInt();
19600 6263211 int32_t by = y.getInt();
19601 6263211 int32_t initk = 0;
19602
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1509828 times.
✓ Branch 2 taken 1221565 times.
✓ Branch 3 taken 1695329 times.
✓ Branch 4 taken 1836489 times.
6263211 switch(dir)
19603 {
19604 case up:
19605
19606 1509828 by-=bigHitbox ? 4 : -4;
19607
19608
2/2
✓ Branch 0 taken 1509776 times.
✓ Branch 1 taken 52 times.
1509828 if(by<0)
19609 {
19610 52 return false;
19611 }
19612 1509776 break;
19613
19614 case down:
19615
19616 1221565 by+=20;
19617
2/2
✓ Branch 0 taken 11062 times.
✓ Branch 1 taken 1210503 times.
1221565 if(by>175)
19618 {
19619 11062 return false;
19620 }
19621
19622 1210503 break;
19623
19624 case left:
19625 1695329 bx-=4;
19626
2/2
✓ Branch 0 taken 9483 times.
✓ Branch 1 taken 1685846 times.
1695329 if (!bigHitbox)
19627 {
19628 1685846 by+=8;
19629 1685846 initk = 1;
19630 1685846 }
19631
2/2
✓ Branch 0 taken 1686508 times.
✓ Branch 1 taken 8821 times.
1695329 if(bx<0)
19632 {
19633 8821 return false;
19634 }
19635
19636 1686508 break;
19637
19638 case right:
19639
19640 1836489 bx+=20;
19641
2/2
✓ Branch 0 taken 13038 times.
✓ Branch 1 taken 1823451 times.
1836489 if (!bigHitbox)
19642 {
19643 1823451 by+=8;
19644 1823451 initk = 1;
19645 1823451 }
19646
2/2
✓ Branch 0 taken 13098 times.
✓ Branch 1 taken 1823391 times.
1836489 if(bx>255)
19647 {
19648 13098 return false;
19649 }
19650
19651 1823391 break;
19652 }
19653 6230178 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
19654 6230178 int32_t t = cmb.type;
19655
2/2
✓ Branch 0 taken 6230062 times.
✓ Branch 1 taken 116 times.
6230178 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19656 116 t = cNONE;
19657 6230178 int32_t initbx = bx;
19658 6230178 int32_t initby = by;
19659
19660 // Unlike push blocks, damage combos should be tested on layers 2 and under
19661
2/2
✓ Branch 0 taken 10260984 times.
✓ Branch 1 taken 6230162 times.
16491146 for(int32_t i=(get_bit(quest_rules,qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
19662 {
19663 10260984 bx = initbx;
19664 10260984 by = initby;
19665
2/2
✓ Branch 0 taken 24998223 times.
✓ Branch 1 taken 10260968 times.
35259191 for (int32_t k = initk; k <= 2; k++)
19666 {
19667 24998223 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
19668 24998223 t = cmb.type;
19669
2/2
✓ Branch 0 taken 24997897 times.
✓ Branch 1 taken 326 times.
24998223 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19670 326 t = cNONE;
19671 // Solid damage combos use pushing>0, hence the code is here.
19672
10/10
✓ Branch 0 taken 381157 times.
✓ Branch 1 taken 24617066 times.
✓ Branch 2 taken 115489 times.
✓ Branch 3 taken 265668 times.
✓ Branch 4 taken 101377 times.
✓ Branch 5 taken 14112 times.
✓ Branch 6 taken 2880 times.
✓ Branch 7 taken 98497 times.
✓ Branch 8 taken 45 times.
✓ Branch 9 taken 2835 times.
24998223 if (!get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
19673 {
19674
14/18
✓ Branch 0 taken 24970185 times.
✓ Branch 1 taken 11091 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11091 times.
✓ Branch 4 taken 11091 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1294 times.
✓ Branch 7 taken 9797 times.
✓ Branch 8 taken 253 times.
✓ Branch 9 taken 1041 times.
✓ Branch 10 taken 160 times.
✓ Branch 11 taken 93 times.
✓ Branch 12 taken 160 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 160 times.
✓ Branch 16 taken 24981216 times.
✓ Branch 17 taken 60 times.
24981276 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting && !get_bit(quest_rules, qr_NOSOLIDDAMAGECOMBOS))
19675 {
19676 // Bite Hero
19677
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 6 times.
60 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
19678 54 }
19679 24981270 }
19680
3/4
✓ Branch 0 taken 842465 times.
✓ Branch 1 taken 24155752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 780689 times.
25778906 if(isSideViewHero() && // Check for sideview damage combos
19681
3/4
✓ Branch 0 taken 780689 times.
✓ Branch 1 taken 61776 times.
✓ Branch 2 taken 780689 times.
✗ Branch 3 not taken.
842465 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
19682 {
19683
2/2
✓ Branch 0 taken 110215 times.
✓ Branch 1 taken 670474 times.
780689 if (get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES))
19684 {
19685
4/6
✓ Branch 0 taken 110215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 110170 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
110215 if (on_sideview_solid_oldpos(x,y,old_x,old_y) && (!getOnSideviewLadder() || DrunkDown()))
19686 {
19687
4/4
✓ Branch 0 taken 110161 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 110165 times.
✓ Branch 3 taken 5 times.
110170 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
19688 {
19689
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
19690 }
19691 110165 }
19692
1/2
✓ Branch 0 taken 110210 times.
✗ Branch 1 not taken.
110210 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
19693 110210 }
19694 else
19695 {
19696 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
19697
1/2
✓ Branch 0 taken 670474 times.
✗ Branch 1 not taken.
670474 if ( get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES ) )
19698 {
19699
2/2
✓ Branch 0 taken 670469 times.
✓ Branch 1 taken 5 times.
1340948 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
19700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
670474 x+8+(zc_max(tmpscr->csensitive-1,0)),
19701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
670474 y+17-(get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
19702
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 670474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
670474 y+17+zc_max((get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
19703 5 return true;
19704 670469 }
19705 else //2.50.1 and later
19706 {
19707 if(checkdamagecombos(x+4, x+12, y+16, y+24))
19708 return true;
19709 }
19710 }
19711
19712 780679 }
19713
2/2
✓ Branch 0 taken 13227546 times.
✓ Branch 1 taken 11770661 times.
24998207 if (dir < left) bx += (k % 2) ? 7 : 8;
19714 11770661 else by += (k % 2) ? 7 : 8;
19715 24998207 }
19716 10260968 }
19717 6230162 return false;
19718 6263211 }
19719 6407879 void HeroClass::checkpushblock()
19720 {
19721
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6394473 times.
6407879 if(toogam) return;
19722
19723
3/4
✓ Branch 0 taken 6390840 times.
✓ Branch 1 taken 3633 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6390840 times.
6394473 if(z!=0||fakez!=0) return;
19724
19725 // Return early in some cases..
19726 6390840 bool earlyReturn=false;
19727
19728
5/6
✓ Branch 0 taken 5682239 times.
✓ Branch 1 taken 708601 times.
✓ Branch 2 taken 5682239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5915649 times.
✓ Branch 5 taken 475191 times.
6390840 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
19729
2/2
✓ Branch 0 taken 2220342 times.
✓ Branch 1 taken 3695307 times.
5915649 if(x.getInt()&15) earlyReturn=true;
19730
19731 // if(y<16) return;
19732
4/4
✓ Branch 0 taken 261476 times.
✓ Branch 1 taken 6129364 times.
✓ Branch 2 taken 133847 times.
✓ Branch 3 taken 127629 times.
6390840 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)) return;
19733
19734 6263211 int32_t bx = x.getInt()&0xF0;
19735 6263211 int32_t by = (y.getInt()&0xF0);
19736
19737
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1509828 times.
✓ Branch 2 taken 1221565 times.
✓ Branch 3 taken 1695329 times.
✓ Branch 4 taken 1836489 times.
6263211 switch(dir)
19738 {
19739 case up:
19740
2/2
✓ Branch 0 taken 50377 times.
✓ Branch 1 taken 1459451 times.
1509828 if(y<16)
19741 {
19742 50377 earlyReturn=true;
19743 50377 break;
19744 }
19745
19746
3/4
✓ Branch 0 taken 267279 times.
✓ Branch 1 taken 1192172 times.
✓ Branch 2 taken 267279 times.
✗ Branch 3 not taken.
1459451 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
19747
19748
2/2
✓ Branch 0 taken 834026 times.
✓ Branch 1 taken 625425 times.
1459451 if((int32_t)x&8) bx+=16;
19749
19750 1459451 break;
19751
19752 case down:
19753
2/2
✓ Branch 0 taken 80721 times.
✓ Branch 1 taken 1140844 times.
1221565 if(y>128)
19754 {
19755 80721 earlyReturn=true;
19756 80721 break;
19757 }
19758 else
19759 {
19760 1140844 by+=16;
19761
19762
2/2
✓ Branch 0 taken 719978 times.
✓ Branch 1 taken 420866 times.
1140844 if((int32_t)x&8) bx+=16;
19763 }
19764
19765 1140844 break;
19766
19767 case left:
19768
2/2
✓ Branch 0 taken 84925 times.
✓ Branch 1 taken 1610404 times.
1695329 if(x<32)
19769 {
19770 84925 earlyReturn=true;
19771 84925 break;
19772 }
19773 else
19774 {
19775 1610404 bx-=16;
19776
19777
2/2
✓ Branch 0 taken 1029157 times.
✓ Branch 1 taken 581247 times.
1610404 if(y.getInt()&8)
19778 {
19779 581247 by+=16;
19780 581247 }
19781 }
19782
19783 1610404 break;
19784
19785 case right:
19786
2/2
✓ Branch 0 taken 88701 times.
✓ Branch 1 taken 1747788 times.
1836489 if(x>208)
19787 {
19788 88701 earlyReturn=true;
19789 88701 break;
19790 }
19791 else
19792 {
19793 1747788 bx+=16;
19794
19795
2/2
✓ Branch 0 taken 1135758 times.
✓ Branch 1 taken 612030 times.
1747788 if(y.getInt()&8)
19796 {
19797 612030 by+=16;
19798 612030 }
19799 }
19800
19801 1747788 break;
19802 }
19803
19804
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6263195 times.
6263211 if (checksoliddamage()) return;
19805
19806
2/2
✓ Branch 0 taken 3760083 times.
✓ Branch 1 taken 2503112 times.
6263195 if(earlyReturn)
19807 3760083 return;
19808
19809 2503112 int itemid=current_item_id(itype_bracelet);
19810 2503112 size_t combopos = (by&0xF0)+(bx>>4);
19811
2/2
✓ Branch 0 taken 952238 times.
✓ Branch 1 taken 1550874 times.
2503112 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
19812
2/2
✓ Branch 0 taken 1550874 times.
✓ Branch 1 taken 952238 times.
2503112 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
19813
2/2
✓ Branch 0 taken 1120765 times.
✓ Branch 1 taken 4762217 times.
5882982 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
19814 {
19815
4/4
✓ Branch 0 taken 1902200 times.
✓ Branch 1 taken 2860017 times.
✓ Branch 2 taken 526175 times.
✓ Branch 3 taken 1376025 times.
4762217 if(get_bit(quest_rules,qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
19816
4/4
✓ Branch 0 taken 2254174 times.
✓ Branch 1 taken 1132018 times.
✓ Branch 2 taken 7022 times.
✓ Branch 3 taken 2247152 times.
3386192 if(lyr && !get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
19817 2247152 continue;
19818 1139040 cpos_info& cpinfo = combo_posinfos[lyr][combopos];
19819 1139040 mapscr* m = FFCore.tempScreens[lyr];
19820
2/2
✓ Branch 0 taken 1127086 times.
✓ Branch 1 taken 11954 times.
1139040 int cid = lyr == 0 ? MAPCOMBO(bx,by) : MAPCOMBOL(lyr,bx,by);
19821 1139040 newcombo const& cmb = combobuf[cid];
19822 1139040 int f = MAPFLAG2(lyr-1,bx,by);
19823 1139040 int f2 = cmb.flag;
19824 1139040 int t = cmb.type;
19825
19826
6/6
✓ Branch 0 taken 1039048 times.
✓ Branch 1 taken 99992 times.
✓ Branch 2 taken 1036289 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 2027 times.
✓ Branch 5 taken 1034262 times.
2173302 bool waitblock = (t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) ||
19827
1/2
✓ Branch 0 taken 1034262 times.
✗ Branch 1 not taken.
1034262 (t == cPUSHBLOCK && (cmb.usrflags&cflag6));
19828 1139040 int heavy = 0;
19829
4/4
✓ Branch 0 taken 1131349 times.
✓ Branch 1 taken 7691 times.
✓ Branch 2 taken 7911 times.
✓ Branch 3 taken 1123438 times.
1139040 if(t==cPUSH_HW || t==cPUSH_HEAVY)
19830 15602 heavy = 1;
19831
4/4
✓ Branch 0 taken 1122132 times.
✓ Branch 1 taken 1306 times.
✓ Branch 2 taken 2027 times.
✓ Branch 3 taken 1120105 times.
1123438 else if(t==cPUSH_HEAVY2 || t==cPUSH_HW2)
19832 3333 heavy = 2;
19833
1/2
✓ Branch 0 taken 1120105 times.
✗ Branch 1 not taken.
1120105 else if(t == cPUSHBLOCK)
19834 heavy = cmb.attribytes[0];
19835
19836
6/6
✓ Branch 0 taken 99846 times.
✓ Branch 1 taken 1039194 times.
✓ Branch 2 taken 34028 times.
✓ Branch 3 taken 65818 times.
✓ Branch 4 taken 2753 times.
✓ Branch 5 taken 31275 times.
1139040 if(waitblock && (pushing<16 || hasMainGuy())) continue;
19837
19838
8/8
✓ Branch 0 taken 10839 times.
✓ Branch 1 taken 1059630 times.
✓ Branch 2 taken 9936 times.
✓ Branch 3 taken 903 times.
✓ Branch 4 taken 741 times.
✓ Branch 5 taken 9195 times.
✓ Branch 6 taken 1644 times.
✓ Branch 7 taken 1068825 times.
1090503 if(heavy && (itemid<0 || glove->power < heavy ||
19839
3/4
✓ Branch 0 taken 9189 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
10839 (limitedpush && usecounts[itemid] > zc_max(1, glove->misc3)))) continue;
19840
19841 1068825 bool doit=false;
19842 1068825 bool changeflag=false;
19843 1068825 bool changecombo=false;
19844
19845 1068825 int blockdir = dir;
19846
1/2
✓ Branch 0 taken 1068825 times.
✗ Branch 1 not taken.
1068825 if(blockdir > 3) blockdir = Y_DIR(dir);
19847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1068825 times.
1068825 if(t == cPUSHBLOCK)
19848 {
19849 switch(blockdir)
19850 {
19851 case up:
19852 doit = cmb.usrflags & cflag1;
19853 break;
19854 case down:
19855 doit = cmb.usrflags & cflag2;
19856 break;
19857 case left:
19858 doit = cmb.usrflags & cflag3;
19859 break;
19860 case right:
19861 doit = cmb.usrflags & cflag4;
19862 break;
19863 }
19864 if(cmb.usrflags & cflag5) //Separate directions
19865 {
19866 if(int limit = cmb.attribytes[4+blockdir])
19867 {
19868 if(cpinfo.pushes[blockdir] >= limit)
19869 doit = false;
19870 }
19871 else if(cmb.usrflags & cflag9)
19872 doit = false;
19873 }
19874 else
19875 {
19876 if(int limit = cmb.attribytes[4])
19877 {
19878 if(cpinfo.sumpush() >= limit)
19879 doit = false;
19880 }
19881 else if(cmb.usrflags & cflag9)
19882 doit = false;
19883 }
19884 }
19885 else
19886 {
19887
8/8
✓ Branch 0 taken 1063697 times.
✓ Branch 1 taken 5128 times.
✓ Branch 2 taken 1063693 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 2741 times.
✓ Branch 5 taken 1066084 times.
✓ Branch 6 taken 367 times.
✓ Branch 7 taken 1060718 times.
2129910 if(((f==mfPUSHUD || f==mfPUSHUDNS|| f==mfPUSHUDINS) && dir<=down) ||
19888
4/4
✓ Branch 0 taken 1063764 times.
✓ Branch 1 taken 2320 times.
✓ Branch 2 taken 1063762 times.
✓ Branch 3 taken 2 times.
1066084 ((f==mfPUSHLR || f==mfPUSHLRNS|| f==mfPUSHLRINS) && dir>=left) ||
19889
4/4
✓ Branch 0 taken 1063747 times.
✓ Branch 1 taken 2337 times.
✓ Branch 2 taken 1063619 times.
✓ Branch 3 taken 128 times.
1066084 ((f==mfPUSHU || f==mfPUSHUNS || f==mfPUSHUINS) && dir==up) ||
19890
3/4
✓ Branch 0 taken 1063705 times.
✓ Branch 1 taken 2379 times.
✓ Branch 2 taken 1063705 times.
✗ Branch 3 not taken.
1066084 ((f==mfPUSHD || f==mfPUSHDNS || f==mfPUSHDINS) && dir==down) ||
19891
3/4
✓ Branch 0 taken 1063607 times.
✓ Branch 1 taken 2477 times.
✓ Branch 2 taken 1063607 times.
✗ Branch 3 not taken.
1066084 ((f==mfPUSHL || f==mfPUSHLNS || f==mfPUSHLINS) && dir==left) ||
19892
3/4
✓ Branch 0 taken 1063628 times.
✓ Branch 1 taken 2456 times.
✓ Branch 2 taken 1063628 times.
✗ Branch 3 not taken.
1066084 ((f==mfPUSHR || f==mfPUSHRNS || f==mfPUSHRINS) && dir==right) ||
19893
2/2
✓ Branch 0 taken 1061085 times.
✓ Branch 1 taken 87 times.
1061172 f==mfPUSH4 || f==mfPUSH4NS || f==mfPUSH4INS)
19894 {
19895 3195 changeflag=true;
19896 3195 doit=true;
19897 3195 }
19898
19899
7/8
✓ Branch 0 taken 1063893 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 1063893 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 1063903 times.
✓ Branch 6 taken 1063892 times.
✓ Branch 7 taken 1 times.
2127796 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
19900
3/4
✓ Branch 0 taken 1063893 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1063893 times.
✗ Branch 3 not taken.
1063903 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
19901
3/4
✓ Branch 0 taken 1063893 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1063893 times.
✗ Branch 3 not taken.
1063903 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
19902
3/4
✓ Branch 0 taken 1063893 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1063893 times.
✗ Branch 3 not taken.
1063903 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
19903
3/4
✓ Branch 0 taken 1063893 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1063893 times.
✗ Branch 3 not taken.
1063903 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
19904
3/4
✓ Branch 0 taken 1063893 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1063893 times.
✗ Branch 3 not taken.
1063903 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
19905
1/2
✓ Branch 0 taken 1063883 times.
✗ Branch 1 not taken.
1063893 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
19906 {
19907 1 changecombo=true;
19908 1 doit=true;
19909 1 }
19910 }
19911
19912
2/2
✓ Branch 0 taken 315236 times.
✓ Branch 1 taken 748657 times.
1063893 if(get_bit(quest_rules,qr_SOLIDBLK))
19913 {
19914
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 82745 times.
✓ Branch 2 taken 73560 times.
✓ Branch 3 taken 71265 times.
✓ Branch 4 taken 87666 times.
315236 switch(blockdir)
19915 {
19916 case up:
19917
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 82745 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82745 times.
✓ Branch 4 taken 51671 times.
✓ Branch 5 taken 31074 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 31074 times.
✓ Branch 8 taken 51675 times.
✓ Branch 9 taken 31070 times.
82745 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
19918
19919 82745 break;
19920
19921 case down:
19922
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 73560 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 73560 times.
✓ Branch 4 taken 44458 times.
✓ Branch 5 taken 29102 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 29102 times.
✓ Branch 8 taken 44462 times.
✓ Branch 9 taken 29098 times.
73560 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
19923
19924 73560 break;
19925
19926 case left:
19927
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 71265 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71265 times.
✓ Branch 4 taken 31068 times.
✓ Branch 5 taken 40197 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 40197 times.
✓ Branch 8 taken 31074 times.
✓ Branch 9 taken 40191 times.
71265 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
19928
19929 71265 break;
19930
19931 case right:
19932
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 87666 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87666 times.
✓ Branch 4 taken 37161 times.
✓ Branch 5 taken 50505 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 50505 times.
✓ Branch 8 taken 37171 times.
✓ Branch 9 taken 50495 times.
87666 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
19933
19934 87666 break;
19935 }
19936 315236 }
19937
19938
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 386557 times.
✓ Branch 2 taken 329275 times.
✓ Branch 3 taken 165414 times.
✓ Branch 4 taken 182647 times.
1063893 switch(blockdir)
19939 {
19940 case up:
19941
3/4
✓ Branch 0 taken 386225 times.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 386225 times.
386557 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
19942
19943 386557 break;
19944
19945 case down:
19946
3/4
✓ Branch 0 taken 328859 times.
✓ Branch 1 taken 416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 328859 times.
329275 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
19947
19948 329275 break;
19949
19950 case left:
19951
3/4
✓ Branch 0 taken 165332 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 165332 times.
165414 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
19952
19953 165414 break;
19954
19955 case right:
19956
3/4
✓ Branch 0 taken 182623 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 182623 times.
182647 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
19957
19958 182647 break;
19959 }
19960
19961
2/2
✓ Branch 0 taken 1062503 times.
✓ Branch 1 taken 1390 times.
1063893 if(doit)
19962 {
19963
2/2
✓ Branch 0 taken 1383 times.
✓ Branch 1 taken 7 times.
1390 if(limitedpush)
19964 7 ++usecounts[itemid];
19965
19966 // for(int32_t i=0; i<1; i++)
19967
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1135 times.
1390 if(!blockmoving)
19968 {
19969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(changeflag)
19970 {
19971 1135 m->sflag[combopos]=0;
19972 1135 }
19973
19974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(mblock2.clk<=0)
19975 {
19976 1135 mblock2.blockLayer = lyr;
19977
19978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(t == cPUSHBLOCK)
19979 {
19980 zfix blockstep = 0.5;
19981 if(cmb.attrishorts[0] > 0)
19982 blockstep = zslongToFix(cmb.attrishorts[0]*100);
19983 mblock2.push_new(zfix(bx),zfix(by),blockdir,f,blockstep);
19984 mblock2.blockinfo = cpinfo;
19985 mblock2.blockinfo.push(blockdir, cmb.usrflags&cflag8);
19986 cpinfo.clear();
19987 if(cmb.attribytes[1])
19988 sfx(cmb.attribytes[1],(int32_t)x);
19989 }
19990 else
19991 {
19992 1135 mblock2.push((zfix)bx,(zfix)by,blockdir,f);
19993
19994
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1133 times.
1135 if(get_bit(quest_rules,qr_MORESOUNDS))
19995 2 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
19996 }
19997 1135 }
19998 1135 }
19999 1390 break;
20000 }
20001 1062503 }
20002 6402947 }
20003
20004 249 bool usekey()
20005 {
20006 249 int32_t itemid = current_item_id(itype_magickey);
20007
20008
3/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
249 if(itemid<0 ||
20009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
20010 : itemsbuf[itemid].power!=dlevel))
20011 {
20012
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 165 times.
200 if(game->lvlkeys[dlevel]!=0)
20013 {
20014 35 game->lvlkeys[dlevel]--;
20015 //run script for level key item
20016 35 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
20017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2975 times.
2975 for ( int32_t q = 0; q < MAXITEMS; ++q )
20018 {
20019
2/2
✓ Branch 0 taken 2940 times.
✓ Branch 1 taken 35 times.
2975 if ( itemsbuf[q].family == itype_lkey )
20020 {
20021 35 key_item = q; break;
20022 }
20023 2940 }
20024
20025
2/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
35 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20026 {
20027 ri = &(itemScriptData[key_item]);
20028 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
20029 ri->Clear();
20030 item_doscript[key_item] = 1;
20031 itemscriptInitialised[key_item] = 0;
20032 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
20033 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
20034 }
20035 35 return true;
20036 }
20037 else
20038 {
20039
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 124 times.
165 if(game->get_keys()==0)
20040 {
20041 41 return false;
20042 }
20043 else
20044 {
20045 //run script for key item
20046 124 int32_t key_item = 0; //current_item_id(itype_key); //not possible
20047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1240 times.
1240 for ( int32_t q = 0; q < MAXITEMS; ++q )
20048 {
20049
2/2
✓ Branch 0 taken 1116 times.
✓ Branch 1 taken 124 times.
1240 if ( itemsbuf[q].family == itype_key )
20050 {
20051 124 key_item = q; break;
20052 }
20053 1116 }
20054 //zprint2("key_item is: %d\n",key_item);
20055 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
20056
2/8
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
124 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20057 {
20058 ri = &(itemScriptData[key_item]);
20059 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
20060 ri->Clear();
20061 item_doscript[key_item] = 1;
20062 itemscriptInitialised[key_item] = 0;
20063 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
20064 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
20065 }
20066 124 game->change_keys(-1);
20067 }
20068 }
20069 124 }
20070
20071 173 return true;
20072 249 }
20073
20074 bool canUseKey(int32_t num)
20075 {
20076 int32_t itemid = current_item_id(itype_magickey);
20077
20078 if(itemid<0 ||
20079 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
20080 : itemsbuf[itemid].power!=dlevel))
20081 {
20082 return game->lvlkeys[dlevel] + game->get_keys() >= num;
20083 }
20084
20085 return true;
20086 }
20087
20088 bool usekey(int32_t num)
20089 {
20090 if(!canUseKey(num)) return false;
20091 for(auto q = 0; q < num; ++q)
20092 {
20093 if(!usekey()) return false; //should never return false here, but, just to be safe....
20094 }
20095 return true;
20096 }
20097
20098
20099 645 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
20100 {
20101 645 int32_t mc = (y&0xF0)+(x>>4);
20102
4/6
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 609 times.
✓ Branch 5 taken 36 times.
1290 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
20103
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 645 times.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 645 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 645 times.
✗ Branch 7 not taken.
645 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
20104
3/6
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 645 times.
✗ Branch 5 not taken.
645 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
20105
5/8
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 637 times.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 637 times.
645 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
20106 645 return ret;
20107 }
20108
20109 6379267 void HeroClass::oldchecklockblock()
20110 {
20111
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6365861 times.
6379267 if(toogam) return;
20112
20113 6365861 int32_t bx = x.getInt()&0xF0;
20114 6365861 int32_t bx2 = int32_t(x+8)&0xF0;
20115 6365861 int32_t by = y.getInt()&0xF0;
20116
20117
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1521387 times.
✓ Branch 2 taken 1225182 times.
✓ Branch 3 taken 1736487 times.
✓ Branch 4 taken 1882805 times.
6365861 switch(dir)
20118 {
20119 case up:
20120
4/4
✓ Branch 0 taken 274847 times.
✓ Branch 1 taken 1246540 times.
✓ Branch 2 taken 5789 times.
✓ Branch 3 taken 269058 times.
1521387 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20121
20122 1521387 break;
20123
20124 case down:
20125 1225182 by+=16;
20126 1225182 break;
20127
20128 case left:
20129
2/2
✓ Branch 0 taken 756479 times.
✓ Branch 1 taken 980008 times.
1736487 if((((int32_t)x)&0x0F)<8)
20130 980008 bx-=16;
20131
20132
2/2
✓ Branch 0 taken 1110887 times.
✓ Branch 1 taken 625600 times.
1736487 if(y.getInt()&8)
20133 {
20134 625600 by+=16;
20135 625600 }
20136
20137 1736487 bx2=bx;
20138 1736487 break;
20139
20140 case right:
20141 1882805 bx+=16;
20142
20143
2/2
✓ Branch 0 taken 1226114 times.
✓ Branch 1 taken 656691 times.
1882805 if(y.getInt()&8)
20144 {
20145 656691 by+=16;
20146 656691 }
20147
20148 1882805 bx2=bx;
20149 1882805 break;
20150 }
20151
20152 6365861 bool found1=false;
20153 6365861 bool found2=false;
20154 6365861 int32_t foundlayer = -1;
20155 6365861 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
20156 6365861 newcombo const& cmb = combobuf[cid1];
20157 6365861 newcombo const& cmb2 = combobuf[cid2];
20158 // Layer 0 is overridden by Locked Doors
20159
5/8
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 6365357 times.
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 504 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 504 times.
6365861 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
20160 {
20161 504 found1=true;
20162 504 foundlayer = 0;
20163 504 }
20164
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6365357 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6365357 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
20165 {
20166 found2=true;
20167 foundlayer = 0;
20168 }
20169
20170
2/2
✓ Branch 0 taken 12731722 times.
✓ Branch 1 taken 6365861 times.
19097583 for (int32_t i = 0; i <= 1; ++i)
20171 {
20172
2/2
✓ Branch 0 taken 10886140 times.
✓ Branch 1 taken 1845582 times.
12731722 if(tmpscr2[i].valid!=0)
20173 {
20174
2/2
✓ Branch 0 taken 1737727 times.
✓ Branch 1 taken 107855 times.
1845582 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20175 {
20176
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
20177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
20178 1737727 }
20179 else
20180 {
20181
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
20182
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
20183 }
20184 1845582 }
20185 12731722 }
20186
20187
20188 // Layers
20189
3/4
✓ Branch 0 taken 6365357 times.
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6365357 times.
6365861 if(!(found1 || found2))
20190 {
20191 6365357 foundlayer = -1;
20192
2/2
✓ Branch 0 taken 6365323 times.
✓ Branch 1 taken 12730680 times.
19096003 for(int32_t i=0; i<2; i++)
20193 {
20194 12730680 cid1 = MAPCOMBO2(i, bx, by);
20195 12730680 cid2 = MAPCOMBO2(i, bx2, by);
20196 12730680 newcombo const& cmb = combobuf[cid1];
20197 12730680 newcombo const& cmb2 = combobuf[cid2];
20198
2/2
✓ Branch 0 taken 6365323 times.
✓ Branch 1 taken 6365357 times.
12730680 if (i == 0)
20199 {
20200
2/2
✓ Branch 0 taken 5997852 times.
✓ Branch 1 taken 367505 times.
6365357 if(tmpscr2[1].valid!=0)
20201 {
20202
2/2
✓ Branch 0 taken 322951 times.
✓ Branch 1 taken 44554 times.
367505 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20203 {
20204
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 322951 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
322951 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
20205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 322951 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
322951 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
20206 322951 }
20207 else
20208 {
20209
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20211 }
20212 367505 }
20213 6365357 }
20214
4/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 12730646 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
12730680 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
20215 {
20216 34 found1=true;
20217 34 foundlayer = i+1;
20218 //zprint("Found layer: %d \n", i);
20219 34 break;
20220 }
20221
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12730646 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12730646 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
20222 {
20223 found2=true;
20224 foundlayer = i+1;
20225 //zprint("Found layer: %d \n", i);
20226 break;
20227 }
20228 12730646 }
20229 6365357 }
20230
20231
4/4
✓ Branch 0 taken 6365323 times.
✓ Branch 1 taken 538 times.
✓ Branch 2 taken 6365812 times.
✓ Branch 3 taken 49 times.
6365861 if(!(found1 || found2) || pushing<8)
20232 {
20233 6365812 return;
20234 }
20235
1/2
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
49 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
20236
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 31 times.
49 if(!try_locked_combo(cmb3))
20237 31 return;
20238
20239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(cmb.usrflags&cflag16)
20240 {
20241 setxmapflag(1<<cmb.attribytes[5]);
20242 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
20243 }
20244 else
20245 {
20246 18 setmapflag(mLOCKBLOCK);
20247 18 remove_lockblocks((currscr>=128)?1:0);
20248 }
20249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( cmb3.usrflags&cflag3 )
20250 {
20251 if ( (cmb3.attribytes[3]) )
20252 sfx(cmb3.attribytes[3]);
20253 }
20254 18 else sfx(WAV_DOOR);
20255 6379267 }
20256
20257 6379267 void HeroClass::oldcheckbosslockblock()
20258 {
20259
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6365861 times.
6379267 if(toogam) return;
20260
20261 6365861 int32_t bx = x.getInt()&0xF0;
20262 6365861 int32_t bx2 = int32_t(x+8)&0xF0;
20263 6365861 int32_t by = y.getInt()&0xF0;
20264
20265
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1521387 times.
✓ Branch 2 taken 1225182 times.
✓ Branch 3 taken 1736487 times.
✓ Branch 4 taken 1882805 times.
6365861 switch(dir)
20266 {
20267 case up:
20268
4/4
✓ Branch 0 taken 274847 times.
✓ Branch 1 taken 1246540 times.
✓ Branch 2 taken 5789 times.
✓ Branch 3 taken 269058 times.
1521387 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20269
20270 1521387 break;
20271
20272 case down:
20273 1225182 by+=16;
20274 1225182 break;
20275
20276 case left:
20277
2/2
✓ Branch 0 taken 756479 times.
✓ Branch 1 taken 980008 times.
1736487 if((((int32_t)x)&0x0F)<8)
20278 980008 bx-=16;
20279
20280
2/2
✓ Branch 0 taken 1110887 times.
✓ Branch 1 taken 625600 times.
1736487 if(y.getInt()&8)
20281 {
20282 625600 by+=16;
20283 625600 }
20284
20285 1736487 bx2=bx;
20286 1736487 break;
20287
20288 case right:
20289 1882805 bx+=16;
20290
20291
2/2
✓ Branch 0 taken 1226114 times.
✓ Branch 1 taken 656691 times.
1882805 if(y.getInt()&8)
20292 {
20293 656691 by+=16;
20294 656691 }
20295
20296 1882805 bx2=bx;
20297 1882805 break;
20298 }
20299
20300
20301 6365861 bool found1 = false;
20302 6365861 bool found2 = false;
20303 6365861 int32_t foundlayer = -1;
20304 6365861 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
20305 6365861 newcombo const& cmb = combobuf[cid1];
20306 6365861 newcombo const& cmb2 = combobuf[cid2];
20307 // Layer 0 is overridden by Locked Doors
20308
5/8
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 6365720 times.
✓ Branch 2 taken 141 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 141 times.
6365861 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
20309 {
20310 141 found1 = true;
20311 141 foundlayer = 0;
20312 141 }
20313
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6365720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6365720 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
20314 {
20315 found2 = true;
20316 foundlayer = 0;
20317 }
20318
20319
2/2
✓ Branch 0 taken 12731722 times.
✓ Branch 1 taken 6365861 times.
19097583 for (int32_t i = 0; i <= 1; ++i)
20320 {
20321
2/2
✓ Branch 0 taken 10886140 times.
✓ Branch 1 taken 1845582 times.
12731722 if (tmpscr2[i].valid != 0)
20322 {
20323
2/2
✓ Branch 0 taken 1737727 times.
✓ Branch 1 taken 107855 times.
1845582 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20324 {
20325
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
20326
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1737727 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1737727 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
20327 1737727 }
20328 else
20329 {
20330
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
20331
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
20332 }
20333 1845582 }
20334 12731722 }
20335
20336
20337 // Layers
20338
3/4
✓ Branch 0 taken 6365720 times.
✓ Branch 1 taken 141 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6365720 times.
6365861 if (!(found1 || found2))
20339 {
20340 6365720 foundlayer = -1;
20341
2/2
✓ Branch 0 taken 6365720 times.
✓ Branch 1 taken 12731440 times.
19097160 for (int32_t i = 0; i < 2; i++)
20342 {
20343 12731440 cid1 = MAPCOMBO2(i, bx, by);
20344 12731440 cid2 = MAPCOMBO2(i, bx2, by);
20345 12731440 newcombo const& cmb = combobuf[cid1];
20346 12731440 newcombo const& cmb2 = combobuf[cid2];
20347
2/2
✓ Branch 0 taken 6365720 times.
✓ Branch 1 taken 6365720 times.
12731440 if (i == 0)
20348 {
20349
2/2
✓ Branch 0 taken 5998072 times.
✓ Branch 1 taken 367648 times.
6365720 if (tmpscr2[1].valid != 0)
20350 {
20351
2/2
✓ Branch 0 taken 323030 times.
✓ Branch 1 taken 44618 times.
367648 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20352 {
20353
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 323030 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
323030 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
20354
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 323030 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
323030 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
20355 323030 }
20356 else
20357 {
20358
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
20359
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
20360 }
20361 367648 }
20362 6365720 }
20363
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12731440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12731440 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
20364 {
20365 found1 = true;
20366 foundlayer = i;
20367 break;
20368 }
20369
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12731440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12731440 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
20370 {
20371 found2 = true;
20372 foundlayer = i;
20373 break;
20374 }
20375 12731440 }
20376 6365720 }
20377
20378
4/4
✓ Branch 0 taken 6365720 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 6365839 times.
✓ Branch 3 taken 22 times.
6365861 if (!(found1 || found2) || pushing < 8)
20379 {
20380 6365839 return;
20381 }
20382
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 int32_t cid = found1 ? cid1 : cid2;
20383
20384
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 17 times.
22 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
20385
20386
20387 // Run Boss Key Script
20388 5 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
20389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 for ( int32_t q = 0; q < MAXITEMS; ++q )
20390 {
20391
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 5 times.
340 if ( itemsbuf[q].family == itype_bosskey )
20392 {
20393 5 key_item = q; break;
20394 }
20395 335 }
20396
2/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20397 {
20398 ri = &(itemScriptData[key_item]);
20399 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
20400 ri->Clear();
20401 item_doscript[key_item] = 1;
20402 itemscriptInitialised[key_item] = 0;
20403 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
20404 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
20405 }
20406
20407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(cmb.usrflags&cflag16)
20408 {
20409 setxmapflag(1<<cmb.attribytes[5]);
20410 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
20411 }
20412 else
20413 {
20414 5 setmapflag(mBOSSLOCKBLOCK);
20415 5 remove_bosslockblocks((currscr>=128)?1:0);
20416 }
20417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if ( (combobuf[cid].attribytes[3]) )
20418 5 sfx(combobuf[cid].attribytes[3]);
20419 6379267 }
20420
20421 18748800 void HeroClass::oldcheckchest(int32_t type)
20422 {
20423 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
20424
5/6
✓ Branch 0 taken 18708582 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 18699525 times.
✓ Branch 3 taken 9057 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18699525 times.
18748800 if(toogam || z>0 || fakez > 0) return;
20425
2/2
✓ Branch 0 taken 17810718 times.
✓ Branch 1 taken 888807 times.
18699525 if(pushing<8) return;
20426 888807 int32_t bx = x.getInt()&0xF0;
20427 888807 int32_t bx2 = int32_t(x+8)&0xF0;
20428 888807 int32_t by = y.getInt()&0xF0;
20429
20430
3/4
✓ Branch 0 taken 498624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 179772 times.
✓ Branch 3 taken 210411 times.
888807 switch(dir)
20431 {
20432 case up:
20433
2/2
✓ Branch 0 taken 40752 times.
✓ Branch 1 taken 169659 times.
210411 if(isSideViewHero()) return;
20434
20435
4/4
✓ Branch 0 taken 49866 times.
✓ Branch 1 taken 119793 times.
✓ Branch 2 taken 48696 times.
✓ Branch 3 taken 1170 times.
169659 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20436
20437 169659 break;
20438
20439 case left:
20440 case right:
20441
2/2
✓ Branch 0 taken 16173 times.
✓ Branch 1 taken 482451 times.
498624 if(isSideViewHero()) break;
20442 [[fallthrough]];
20443 case down:
20444 662223 return;
20445 }
20446
20447 185832 bool found=false;
20448 185832 bool itemflag=false;
20449
20450
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 185824 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
185832 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
20451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185824 times.
185824 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
20452 {
20453 8 found=true;
20454 8 }
20455
2/2
✓ Branch 0 taken 371664 times.
✓ Branch 1 taken 185832 times.
557496 for (int32_t i = 0; i <= 1; ++i)
20456 {
20457
2/2
✓ Branch 0 taken 323724 times.
✓ Branch 1 taken 47940 times.
371664 if(tmpscr2[i].valid!=0)
20458 {
20459
2/2
✓ Branch 0 taken 47079 times.
✓ Branch 1 taken 861 times.
47940 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20460 {
20461
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47079 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
20462
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47079 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
20463 47079 }
20464 else
20465 {
20466
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
20467
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
20468 }
20469 47940 }
20470 371664 }
20471
20472
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 185824 times.
185832 if(!found)
20473 {
20474
2/2
✓ Branch 0 taken 185824 times.
✓ Branch 1 taken 371648 times.
557472 for(int32_t i=0; i<2; i++)
20475 {
20476
2/2
✓ Branch 0 taken 185824 times.
✓ Branch 1 taken 185824 times.
371648 if (i == 0)
20477 {
20478
2/2
✓ Branch 0 taken 177649 times.
✓ Branch 1 taken 8175 times.
185824 if(tmpscr2[1].valid!=0)
20479 {
20480
2/2
✓ Branch 0 taken 7794 times.
✓ Branch 1 taken 381 times.
8175 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20481 {
20482
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7794 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20483
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7794 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20484 7794 }
20485 else
20486 {
20487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20488
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20489 }
20490 8175 }
20491 185824 }
20492
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 371648 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
371648 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
20493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 371648 times.
371648 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
20494 {
20495 found=true;
20496 break;
20497 }
20498 371648 }
20499 185824 }
20500
20501
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 185824 times.
185832 if(!found)
20502 {
20503 185824 return;
20504 }
20505
20506
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 switch(type)
20507 {
20508 case cLOCKEDCHEST:
20509 if(!usekey()) return;
20510
20511 setmapflag(mLOCKEDCHEST);
20512 break;
20513
20514 case cCHEST:
20515 8 setmapflag(mCHEST);
20516 8 break;
20517
20518 case cBOSSCHEST:
20519 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
20520 // Run Boss Key Script
20521 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
20522 for ( int32_t q = 0; q < MAXITEMS; ++q )
20523 {
20524 if ( itemsbuf[q].family == itype_bosskey )
20525 {
20526 key_item = q; break;
20527 }
20528 }
20529 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
20530 {
20531 ri = &(itemScriptData[key_item]);
20532 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
20533 ri->Clear();
20534 item_doscript[key_item] = 1;
20535 itemscriptInitialised[key_item] = 0;
20536 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
20537 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
20538 }
20539 setmapflag(mBOSSCHEST);
20540 break;
20541 }
20542
20543 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
20544 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
20545 8 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
20546 8 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
20547 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
20548 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
20549
20550
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!itemflag)
20551 {
20552 for(int32_t i=0; i<2; i++)
20553 {
20554 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
20555 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
20556 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
20557 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
20558 }
20559 }
20560
20561
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
8 if(itemflag && !getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
20562 {
20563
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
8 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
20564 8 }
20565 18748800 }
20566
20567 532045 void HeroClass::checkchest(int32_t type)
20568 {
20569
4/4
✓ Branch 0 taken 373772 times.
✓ Branch 1 taken 158273 times.
✓ Branch 2 taken 158273 times.
✓ Branch 3 taken 215499 times.
532045 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
20570
2/2
✓ Branch 0 taken 28613 times.
✓ Branch 1 taken 503432 times.
532045 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
20571
2/2
✓ Branch 0 taken 28613 times.
✓ Branch 1 taken 503432 times.
532045 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
20572
2/2
✓ Branch 0 taken 28613 times.
✓ Branch 1 taken 503432 times.
532045 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
20573
2/2
✓ Branch 0 taken 57226 times.
✓ Branch 1 taken 474819 times.
532045 if(ischest)
20574 {
20575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474819 times.
474819 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
20576 {
20577 oldcheckchest(type);
20578 return;
20579 }
20580 474819 }
20581
3/4
✓ Branch 0 taken 57226 times.
✓ Branch 1 taken 474819 times.
✓ Branch 2 taken 57226 times.
✗ Branch 3 not taken.
532045 if(islockblock && get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
20582 {
20583 if(type == cLOCKBLOCK)
20584 oldchecklockblock();
20585 else if(type == cBOSSLOCKBLOCK)
20586 oldcheckbosslockblock();
20587 return;
20588 }
20589
4/6
✓ Branch 0 taken 532045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 529469 times.
✓ Branch 3 taken 2576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 529469 times.
532045 if(toogam || z>0 || fakez > 0) return;
20590 529469 zfix bx, by;
20591 529469 zfix bx2, by2;
20592 529469 zfix fx(-1), fy(-1);
20593
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 106993 times.
✓ Branch 2 taken 119639 times.
✓ Branch 3 taken 139499 times.
✓ Branch 4 taken 163338 times.
529469 switch(dir)
20594 {
20595 case up:
20596 106993 by = y + (bigHitbox ? -2 : 6);
20597 106993 by2 = by;
20598 106993 bx = x + 4;
20599 106993 bx2 = bx + 8;
20600 106993 break;
20601 case down:
20602 119639 by = y + 17;
20603 119639 by2 = by;
20604 119639 bx = x + 4;
20605 119639 bx2 = bx + 8;
20606 119639 break;
20607 case left:
20608 139499 by = y + (bigHitbox ? 0 : 8);
20609 139499 by2 = y + 8;
20610 139499 bx = x - 2;
20611 139499 bx2 = x - 2;
20612 139499 break;
20613 case right:
20614 163338 by = y + (bigHitbox ? 0 : 8);
20615 163338 by2 = y + 8;
20616 163338 bx = x + 17;
20617 163338 bx2 = x + 17;
20618 163338 break;
20619 }
20620
20621 529469 int32_t found = -1;
20622 529469 int32_t foundlayer = 0;
20623
20624 529469 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
20625
20626
4/6
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 528598 times.
✓ Branch 2 taken 871 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 871 times.
529469 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
20627 {
20628 871 found = MAPCOMBO(bx,by);
20629 871 fx = bx; fy = by;
20630
2/2
✓ Branch 0 taken 1742 times.
✓ Branch 1 taken 871 times.
2613 for (int32_t i = 0; i <= 1; ++i)
20631 {
20632
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1357 times.
1742 if(tmpscr2[i].valid!=0)
20633 {
20634
1/2
✓ Branch 0 taken 1357 times.
✗ Branch 1 not taken.
1357 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20635 {
20636
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1357 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1357 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20637 1357 }
20638 else
20639 {
20640 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20641 }
20642 1357 }
20643 1742 }
20644 871 }
20645
2/2
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 528598 times.
529469 if(found<0)
20646 {
20647 528598 cmb = &combobuf[MAPCOMBO(bx2,by2)];
20648
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 528575 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
528598 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
20649 {
20650 23 found = MAPCOMBO(bx2,by2);
20651
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 161 times.
184 for (int32_t i = 0; i <= 6; ++i)
20652 {
20653
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 46 times.
161 if(tmpscr2[i].valid!=0)
20654 {
20655
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20656 {
20657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
20658 {
20659 found = -1;
20660 break;
20661 }
20662 46 }
20663 else
20664 {
20665 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
20666 {
20667 found = -1;
20668 break;
20669 }
20670 }
20671 46 }
20672 161 }
20673
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(found != -1)
20674 {
20675 23 fx = bx2; fy = by2;
20676 23 }
20677 23 }
20678 528598 }
20679
20680
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 528575 times.
529469 if(found<0)
20681 {
20682
2/2
✓ Branch 0 taken 528522 times.
✓ Branch 1 taken 3171185 times.
3699707 for(int32_t i=0; i<6; i++)
20683 {
20684 3171185 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
20685
4/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 3171132 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
3171185 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
20686 {
20687 53 found = MAPCOMBO2(i,bx,by);
20688
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 265 times.
318 for(int32_t j = i+1; j < 6; ++j)
20689 {
20690
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 53 times.
265 if (tmpscr2[j].valid!=0)
20691 {
20692
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20693 {
20694
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
20695 {
20696 found = -1;
20697 break;
20698 }
20699 53 }
20700 else
20701 {
20702 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
20703 {
20704 found = -1;
20705 break;
20706 }
20707 }
20708 53 }
20709 265 }
20710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(found>-1)
20711 {
20712 53 foundlayer = i+1;
20713 53 fx = bx; fy = by;
20714 53 break;
20715 }
20716 }
20717 3171132 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
20718
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3171132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3171132 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
20719 {
20720 found = MAPCOMBO2(i,bx2,by2);
20721 for(int32_t j = i+1; j < 6; ++j)
20722 {
20723 if (tmpscr2[j].valid!=0)
20724 {
20725 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20726 {
20727 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
20728 {
20729 found = -1;
20730 break;
20731 }
20732 }
20733 else
20734 {
20735 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
20736 {
20737 found = -1;
20738 break;
20739 }
20740 }
20741 }
20742 }
20743 if(found>-1)
20744 {
20745 foundlayer = i+1;
20746 fx = bx2; fy = by2;
20747 break;
20748 }
20749 }
20750 3171132 }
20751 528575 }
20752
20753
2/2
✓ Branch 0 taken 947 times.
✓ Branch 1 taken 528522 times.
529469 if(found<0) return;
20754 947 cmb = &combobuf[found];
20755
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
947 switch(dir)
20756 {
20757 case up:
20758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags&cflag10)
20759 return;
20760 947 break;
20761 case down:
20762 if(cmb->usrflags&cflag9)
20763 return;
20764 break;
20765 case left:
20766 if(cmb->usrflags&cflag12)
20767 return;
20768 break;
20769 case right:
20770 if(cmb->usrflags&cflag11)
20771 return;
20772 break;
20773 }
20774 947 int32_t intbtn = cmb->attribytes[2];
20775
20776
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(intbtn) //
20777 {
20778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags & cflag13) //display prompt
20779 {
20780 947 int altcmb = cmb->attributes[2]/10000;
20781 947 prompt_combo = cmb->attributes[1]/10000;
20782
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
947 if(altcmb && ((islocked && !can_locked_combo(*cmb))
20783 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
20784 prompt_combo = altcmb;
20785 947 prompt_cset = cmb->attribytes[4];
20786 947 prompt_x = cmb->attrishorts[0];
20787 947 prompt_y = cmb->attrishorts[1];
20788 947 }
20789
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 935 times.
947 if(!getIntBtnInput(intbtn, true, true, false, false))
20790 {
20791 935 return; //Button not pressed
20792 }
20793 12 }
20794 else if(pushing < 8 || pushing % 8) return; //Not pushing against chest enough
20795
20796
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(ischest)
20797 {
20798
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
20799 12 }
20800 else if(islockblock)
20801 {
20802 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
20803 }
20804
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(intbtn && (cmb->usrflags & cflag13))
20805 12 prompt_combo = 0;
20806 532045 }
20807
20808 6418559 void HeroClass::checkgenpush()
20809 {
20810
4/4
✓ Branch 0 taken 301053 times.
✓ Branch 1 taken 6117506 times.
✓ Branch 2 taken 257153 times.
✓ Branch 3 taken 43900 times.
6418559 if(pushing < 8 || pushing % 8) return;
20811 43900 zfix bx, by;
20812 43900 zfix bx2, by2;
20813
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10530 times.
✓ Branch 2 taken 9103 times.
✓ Branch 3 taken 11637 times.
✓ Branch 4 taken 12630 times.
43900 switch(dir)
20814 {
20815 case up:
20816 10530 by = y + (bigHitbox ? -2 : 6);
20817 10530 by2 = by;
20818 10530 bx = x + 4;
20819 10530 bx2 = bx + 8;
20820 10530 break;
20821 case down:
20822 9103 by = y + 17;
20823 9103 by2 = by;
20824 9103 bx = x + 4;
20825 9103 bx2 = bx + 8;
20826 9103 break;
20827 case left:
20828 11637 by = y + (bigHitbox ? 0 : 8);
20829 11637 by2 = y + 8;
20830 11637 bx = x - 2;
20831 11637 bx2 = x - 2;
20832 11637 break;
20833 case right:
20834 12630 by = y + (bigHitbox ? 0 : 8);
20835 12630 by2 = y + 8;
20836 12630 bx = x + 17;
20837 12630 bx2 = x + 17;
20838 12630 break;
20839 }
20840 43900 auto pos1 = COMBOPOS(bx,by);
20841 43900 auto pos2 = COMBOPOS(bx2,by2);
20842
2/2
✓ Branch 0 taken 43900 times.
✓ Branch 1 taken 307300 times.
351200 for(auto layer = 0; layer < 7; ++layer)
20843 {
20844 307300 mapscr* tmp = FFCore.tempScreens[layer];
20845
20846 307300 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
20847
2/2
✓ Branch 0 taken 307299 times.
✓ Branch 1 taken 1 times.
307300 if(cmb1.triggerflags[1] & combotriggerPUSH)
20848 1 do_trigger_combo(layer,pos1);
20849
20850
2/2
✓ Branch 0 taken 259644 times.
✓ Branch 1 taken 47656 times.
307300 if(pos1==pos2) continue;
20851
20852 47656 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
20853
1/2
✓ Branch 0 taken 47656 times.
✗ Branch 1 not taken.
47656 if(cmb2.triggerflags[1] & combotriggerPUSH)
20854 do_trigger_combo(layer,pos2);
20855 47656 }
20856
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 43078 times.
43900 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
20857 {
20858 822 word c = tmpscr->numFFC();
20859
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 5127 times.
5949 for(word i=0; i<c; i++)
20860 {
20861
4/4
✓ Branch 0 taken 5056 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 5046 times.
5127 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
20862 {
20863 81 ffcdata& ffc = tmpscr->ffcs[i];
20864 81 newcombo const& cmb3 = combobuf[ffc.getData()];
20865
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(cmb3.triggerflags[1] & combotriggerPUSH)
20866 {
20867 do_trigger_combo_ffc(i);
20868 break;
20869 }
20870 81 }
20871 5127 }
20872 822 }
20873 6418559 }
20874
20875 6418560 void HeroClass::checksigns() //Also checks for generic trigger buttons
20876 {
20877
5/6
✓ Branch 0 taken 6405154 times.
✓ Branch 1 taken 13406 times.
✓ Branch 2 taken 6401513 times.
✓ Branch 3 taken 3641 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6401513 times.
6418560 if(toogam || z>0 || fakez>0) return;
20878
5/6
✓ Branch 0 taken 6353158 times.
✓ Branch 1 taken 48355 times.
✓ Branch 2 taken 107120 times.
✓ Branch 3 taken 6246038 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 107120 times.
6401513 if(msg_active || (msg_onscreen && get_bit(quest_rules, qr_MSGDISAPPEAR)))
20879 48355 return; //Don't overwrite a message waiting to be dismissed
20880 6353158 zfix bx, by;
20881 6353158 zfix bx2, by2;
20882 6353158 zfix fx(-1), fy(-1);
20883
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1485572 times.
✓ Branch 2 taken 1230209 times.
✓ Branch 3 taken 1739229 times.
✓ Branch 4 taken 1898148 times.
6353158 switch(dir)
20884 {
20885 case up:
20886 1485572 by = y + (bigHitbox ? -2 : 6);
20887 1485572 by2 = by;
20888 1485572 bx = x + 4;
20889 1485572 bx2 = bx + 8;
20890 1485572 break;
20891 case down:
20892 1230209 by = y + 17;
20893 1230209 by2 = by;
20894 1230209 bx = x + 4;
20895 1230209 bx2 = bx + 8;
20896 1230209 break;
20897 case left:
20898 1739229 by = y + (bigHitbox ? 0 : 8);
20899 1739229 by2 = y + 8;
20900 1739229 bx = x - 2;
20901 1739229 bx2 = x - 2;
20902 1739229 break;
20903 case right:
20904 1898148 by = y + (bigHitbox ? 0 : 8);
20905 1898148 by2 = y + 8;
20906 1898148 bx = x + 17;
20907 1898148 bx2 = x + 17;
20908 1898148 break;
20909 }
20910
20911 6353158 int32_t found = -1;
20912 6353158 int32_t foundffc = -1;
20913 6353158 int32_t found_lyr = 0;
20914 6353158 bool found_sign = false;
20915 6353158 int32_t tmp_cid = MAPCOMBO(bx,by);
20916 6353158 newcombo const* tmp_cmb = &combobuf[tmp_cid];
20917
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6353158 times.
✓ Branch 2 taken 6352512 times.
✓ Branch 3 taken 646 times.
12706316 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
20918 6353158 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
20919 {
20920 646 found = tmp_cid;
20921 646 fx = bx; fy = by;
20922
2/2
✓ Branch 0 taken 1292 times.
✓ Branch 1 taken 646 times.
1938 for (int32_t i = 0; i <= 1; ++i)
20923 {
20924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
1292 if(tmpscr2[i].valid!=0)
20925 {
20926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
1292 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20927 {
20928 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20929 }
20930 else
20931 {
20932
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1292 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20933 }
20934 1292 }
20935 1292 }
20936 646 }
20937 6353158 tmp_cid = MAPCOMBO(bx2,by2);
20938 6353158 tmp_cmb = &combobuf[tmp_cid];
20939
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6353158 times.
✓ Branch 2 taken 6352572 times.
✓ Branch 3 taken 586 times.
12706316 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
20940 6353158 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
20941 {
20942 586 found = tmp_cid;
20943 586 fx = bx2; fy = by2;
20944
2/2
✓ Branch 0 taken 1172 times.
✓ Branch 1 taken 586 times.
1758 for (int32_t i = 0; i <= 1; ++i)
20945 {
20946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
1172 if(tmpscr2[i].valid!=0)
20947 {
20948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
1172 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20949 {
20950 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
20951 }
20952 else
20953 {
20954
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1172 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
20955 }
20956 1172 }
20957 1172 }
20958 586 }
20959
20960
2/2
✓ Branch 0 taken 6195791 times.
✓ Branch 1 taken 157367 times.
6353158 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
20961 {
20962 157367 word c = tmpscr->numFFC();
20963
2/2
✓ Branch 0 taken 157367 times.
✓ Branch 1 taken 889695 times.
1047062 for(word i=0; i<c; i++)
20964 {
20965
4/4
✓ Branch 0 taken 882335 times.
✓ Branch 1 taken 7360 times.
✓ Branch 2 taken 547 times.
✓ Branch 3 taken 881788 times.
889695 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
20966 {
20967 7907 ffcdata& ffc = tmpscr->ffcs[i];
20968 7907 tmp_cmb = &combobuf[ffc.getData()];
20969
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7907 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7907 times.
7907 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
20970 7907 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
20971 {
20972 foundffc = i;
20973 break;
20974 }
20975 7907 }
20976 889695 }
20977 157367 }
20978
20979
3/4
✓ Branch 0 taken 6352509 times.
✓ Branch 1 taken 649 times.
✓ Branch 2 taken 6352509 times.
✗ Branch 3 not taken.
6353158 if(found<0 && foundffc < 0)
20980 {
20981
2/2
✓ Branch 0 taken 6351937 times.
✓ Branch 1 taken 38112194 times.
44464131 for(int32_t i=0; i<6; i++)
20982 {
20983 38112194 tmp_cid = MAPCOMBO2(i,bx,by);
20984 38112194 tmp_cmb = &combobuf[tmp_cid];
20985
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38112194 times.
✓ Branch 2 taken 38111622 times.
✓ Branch 3 taken 572 times.
76224388 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
20986 38112194 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
20987 {
20988 572 found = tmp_cid;
20989 572 found_lyr = i+1;
20990 572 fx = bx; fy = by;
20991
3/4
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 440 times.
572 if (i == 0 && tmpscr2[1].valid!=0)
20992 {
20993
1/2
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
440 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20994 {
20995
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
440 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
20996 440 }
20997 else
20998 {
20999 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
21000 }
21001 440 }
21002 572 }
21003 38112194 tmp_cid = MAPCOMBO2(i,bx2,by2);
21004 38112194 tmp_cmb = &combobuf[tmp_cid];
21005
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38112194 times.
✓ Branch 2 taken 38111678 times.
✓ Branch 3 taken 516 times.
76224388 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
21006 38112194 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
21007 {
21008 516 found = tmp_cid;
21009 516 found_lyr = i+1;
21010 516 fx = bx2; fy = by2;
21011
3/4
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 390 times.
516 if (i == 0 && tmpscr2[1].valid!=0)
21012 {
21013
1/2
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
390 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
21014 {
21015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
390 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
21016 390 }
21017 else
21018 {
21019 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
21020 }
21021 390 }
21022 516 }
21023
2/2
✓ Branch 0 taken 38111622 times.
✓ Branch 1 taken 572 times.
38112194 if(found>-1) break;
21024 38111622 }
21025 6352509 }
21026
21027
3/4
✓ Branch 0 taken 6351937 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 6351937 times.
✗ Branch 3 not taken.
6353158 if(found<0&&foundffc<0) return;
21028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].getData()]);
21029
21030 1221 byte signInput = 0;
21031 1221 bool didsign = false;
21032
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1221 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
21033 {
21034 switch(dir)
21035 {
21036 case up:
21037 if(cmb.usrflags&cflag10)
21038 goto endsigns;
21039 break;
21040 case down:
21041 if(cmb.usrflags&cflag9)
21042 goto endsigns;
21043 break;
21044 case left:
21045 if(cmb.usrflags&cflag12)
21046 goto endsigns;
21047 break;
21048 case right:
21049 if(cmb.usrflags&cflag11)
21050 goto endsigns;
21051 break;
21052 }
21053 int32_t intbtn = cmb.attribytes[2];
21054
21055 if(intbtn) //
21056 {
21057 signInput = getIntBtnInput(intbtn, true, true, false, false);
21058 if(!signInput)
21059 {
21060 if(cmb.usrflags & cflag13) //display prompt
21061 {
21062 prompt_combo = cmb.attributes[1]/10000;
21063 prompt_cset = cmb.attribytes[4];
21064 prompt_x = cmb.attrishorts[0];
21065 prompt_y = cmb.attrishorts[1];
21066 }
21067 goto endsigns; //Button not pressed
21068 }
21069 }
21070 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
21071
21072 trigger_sign(cmb);
21073 didsign = true;
21074 }
21075 endsigns:
21076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 if(on_cooldown(found_lyr, COMBOPOS(fx,fy))) return;
21077
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 431 times.
✓ Branch 3 taken 309 times.
✓ Branch 4 taken 228 times.
1221 switch(dir)
21078 {
21079 case down:
21080
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
21081 return;
21082 253 break;
21083 case up:
21084
1/2
✓ Branch 0 taken 431 times.
✗ Branch 1 not taken.
431 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
21085 return;
21086 431 break;
21087 case right:
21088
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
21089 return;
21090 309 break;
21091 case left:
21092
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 75 times.
228 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
21093 75 return;
21094 153 break;
21095 }
21096
4/6
✓ Branch 0 taken 1146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1114 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1114 times.
1146 if(cmb.triggerbtn && (getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput)))
21097 {
21098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if (foundffc >= 0)
21099 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
21100 else
21101 32 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
21102 32 }
21103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(cmb.type == cBUTTONPROMPT)
21104 {
21105 prompt_combo = cmb.attributes[0]/10000;
21106 prompt_cset = cmb.attribytes[0];
21107 prompt_x = cmb.attrishorts[0];
21108 prompt_y = cmb.attrishorts[1];
21109 }
21110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(cmb.prompt_cid)
21111 {
21112 1114 prompt_combo = cmb.prompt_cid;
21113 1114 prompt_cset = cmb.prompt_cs;
21114 1114 prompt_x = cmb.prompt_x;
21115 1114 prompt_y = cmb.prompt_y;
21116 1114 }
21117 6418560 }
21118
21119 6407879 void HeroClass::checklocked()
21120 {
21121
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6394473 times.
6407879 if(toogam) return; //Walk through walls.
21122
21123
2/2
✓ Branch 0 taken 3646327 times.
✓ Branch 1 taken 2748146 times.
6394473 if(!isdungeon()) return;
21124
21125
4/4
✓ Branch 0 taken 3645689 times.
✓ Branch 1 taken 638 times.
✓ Branch 2 taken 7738 times.
✓ Branch 3 taken 3637951 times.
3646327 if( !diagonalMovement && pushing!=8) return;
21126 /*This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
21127 */
21128
4/4
✓ Branch 0 taken 638 times.
✓ Branch 1 taken 7738 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 628 times.
8376 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
21129
21130
21131 7748 bool found = false;
21132
2/2
✓ Branch 0 taken 30992 times.
✓ Branch 1 taken 7748 times.
38740 for ( int32_t q = 0; q < 4; q++ ) {
21133
4/4
✓ Branch 0 taken 30264 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 30018 times.
30992 if ( tmpscr->door[q] == dLOCKED || tmpscr->door[q] == dBOSS ) { found = true; }
21134 30992 }
21135
21136
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 6805 times.
7748 if ( !found ) return;
21137
21138 943 int32_t si = (currmap<<7) + currscr;
21139 943 int32_t di = 0;
21140
21141
21142
21143
2/4
✓ Branch 0 taken 943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 943 times.
943 if ( diagonalMovement || get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
21144 {
21145 //Up door
21146 if ( y <= 32 && x >= 112 && x <= 128 )
21147 {
21148 if (
21149 dir == up || dir == l_up || dir == r_up //|| Up() || ( Up()&&Left()) || ( Up()&&Right())
21150
21151 )
21152 {
21153 di = nextscr(up);
21154 if(tmpscr->door[0]==dLOCKED)
21155 {
21156 if(usekey())
21157 {
21158 putdoor(scrollbuf,0,up,dUNLOCKED);
21159 tmpscr->door[0]=dUNLOCKED;
21160 setmapflag(si, mDOOR_UP);
21161
21162 if(di != 0xFFFF)
21163 setmapflag(di, mDOOR_DOWN);
21164 sfx(WAV_DOOR);
21165 markBmap(-1);
21166 }
21167 else return;
21168 }
21169 else if(tmpscr->door[0]==dBOSS)
21170 {
21171 if(game->lvlitems[dlevel]&liBOSSKEY)
21172 {
21173 putdoor(scrollbuf,0,up,dOPENBOSS);
21174 tmpscr->door[0]=dOPENBOSS;
21175 setmapflag(si, mDOOR_UP);
21176
21177 if(di != 0xFFFF)
21178 setmapflag(di, mDOOR_DOWN);
21179 sfx(WAV_DOOR);
21180 markBmap(-1);
21181 // Run Boss Key Script
21182 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21183 for ( int32_t q = 0; q < MAXITEMS; ++q )
21184 {
21185 if ( itemsbuf[q].family == itype_bosskey )
21186 {
21187 key_item = q; break;
21188 }
21189 }
21190 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21191 {
21192 ri = &(itemScriptData[key_item]);
21193 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21194 ri->Clear();
21195 item_doscript[key_item] = 1;
21196 itemscriptInitialised[key_item] = 0;
21197 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21198 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21199 }
21200 }
21201 else return;
21202
21203 }
21204
21205 }
21206 }
21207 //Down
21208 if ( y >= 128 && x >= 112 && x <= 128 )
21209 {
21210 if ( dir == down || dir == l_down || dir == r_down ) //|| Down() || ( Down()&&Left()) || ( Down()&&Right()))
21211 {
21212 di = nextscr(down);
21213 if(tmpscr->door[1]==dLOCKED)
21214 {
21215 if(usekey())
21216 {
21217 putdoor(scrollbuf,0,down,dUNLOCKED);
21218 tmpscr->door[1]=dUNLOCKED;
21219 setmapflag(si, mDOOR_DOWN);
21220
21221 if(di != 0xFFFF)
21222 setmapflag(di, mDOOR_UP);
21223 sfx(WAV_DOOR);
21224 markBmap(-1);
21225 }
21226 else return;
21227 }
21228 else if(tmpscr->door[1]==dBOSS)
21229 {
21230 if(game->lvlitems[dlevel]&liBOSSKEY)
21231 {
21232 putdoor(scrollbuf,0,down,dOPENBOSS);
21233 tmpscr->door[1]=dOPENBOSS;
21234 setmapflag(si, mDOOR_DOWN);
21235
21236 if(di != 0xFFFF)
21237 setmapflag(di, mDOOR_UP);
21238 sfx(WAV_DOOR);
21239 markBmap(-1);
21240 // Run Boss Key Script
21241 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21242 for ( int32_t q = 0; q < MAXITEMS; ++q )
21243 {
21244 if ( itemsbuf[q].family == itype_bosskey )
21245 {
21246 key_item = q; break;
21247 }
21248 }
21249 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21250 {
21251 ri = &(itemScriptData[key_item]);
21252 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21253 ri->Clear();
21254 item_doscript[key_item] = 1;
21255 itemscriptInitialised[key_item] = 0;
21256 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21257 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21258 }
21259 }
21260 else return;
21261 }
21262 }
21263 }
21264 //left
21265 if ( y > 72 && y < 88 && x <= 32 )
21266 {
21267 if ( dir == left || dir == l_up || dir == l_down )//|| Left() || ( Up()&&Left()) || ( Down()&&Left() ) )
21268 {
21269 di = nextscr(left);
21270 if(tmpscr->door[2]==dLOCKED)
21271 {
21272 if(usekey())
21273 {
21274 putdoor(scrollbuf,0,left,dUNLOCKED);
21275 tmpscr->door[2]=dUNLOCKED;
21276 setmapflag(si, mDOOR_LEFT);
21277
21278 if(di != 0xFFFF)
21279 setmapflag(di, mDOOR_RIGHT);
21280 sfx(WAV_DOOR);
21281 markBmap(-1);
21282 }
21283 else return;
21284 }
21285 else if(tmpscr->door[2]==dBOSS)
21286 {
21287 if(game->lvlitems[dlevel]&liBOSSKEY)
21288 {
21289 putdoor(scrollbuf,0,left,dOPENBOSS);
21290 tmpscr->door[2]=dOPENBOSS;
21291 setmapflag(si, mDOOR_LEFT);
21292
21293 if(di != 0xFFFF)
21294 setmapflag(di, mDOOR_RIGHT);
21295 sfx(WAV_DOOR);
21296 markBmap(-1);
21297 // Run Boss Key Script
21298 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21299 for ( int32_t q = 0; q < MAXITEMS; ++q )
21300 {
21301 if ( itemsbuf[q].family == itype_bosskey )
21302 {
21303 key_item = q; break;
21304 }
21305 }
21306 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21307 {
21308 ri = &(itemScriptData[key_item]);
21309 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21310 ri->Clear();
21311 item_doscript[key_item] = 1;
21312 itemscriptInitialised[key_item] = 0;
21313 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21314 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21315 }
21316 }
21317 else return;
21318 }
21319 }
21320 }
21321
21322
21323 //right
21324 if ( ( y > 72 && y < 88 ) && x >= 208 )
21325 //!( (y<=72||y>=88) && x<206 ) )
21326 //y<=72||y>=88):y!=80) || x<208)
21327 {
21328 if ( dir == right || dir == r_up || dir == r_down ) //|| Right() || ( Down()&&Right() ) || ( Up()&&Right()))
21329 {
21330 di = nextscr(right);
21331 if(tmpscr->door[right]==dLOCKED)
21332 {
21333 if(usekey())
21334 {
21335 putdoor(scrollbuf,0,right,dUNLOCKED);
21336 tmpscr->door[3]=dUNLOCKED;
21337 setmapflag(si, mDOOR_RIGHT);
21338
21339 if(di != 0xFFFF)
21340 setmapflag(di, mDOOR_LEFT);
21341 sfx(WAV_DOOR);
21342 markBmap(-1);
21343 }
21344 else return;
21345 }
21346 else if(tmpscr->door[right]==dBOSS)
21347 {
21348 if(game->lvlitems[dlevel]&liBOSSKEY)
21349 {
21350 putdoor(scrollbuf,0,right,dOPENBOSS);
21351 tmpscr->door[3]=dOPENBOSS;
21352 setmapflag(si, mDOOR_RIGHT);
21353
21354 if(di != 0xFFFF)
21355 setmapflag(di, mDOOR_LEFT);
21356 sfx(WAV_DOOR);
21357 markBmap(-1);
21358 // Run Boss Key Script
21359 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21360 for ( int32_t q = 0; q < MAXITEMS; ++q )
21361 {
21362 if ( itemsbuf[q].family == itype_bosskey )
21363 {
21364 key_item = q; break;
21365 }
21366 }
21367 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21368 {
21369 ri = &(itemScriptData[key_item]);
21370 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21371 ri->Clear();
21372 item_doscript[key_item] = 1;
21373 itemscriptInitialised[key_item] = 0;
21374 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21375 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21376 }
21377 }
21378 else return;
21379 }
21380
21381 }
21382 }
21383 }
21384 else
21385 {
21386 //orthogonal movement
21387 //Up door
21388
4/4
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 746 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 118 times.
943 if ( y<=32 && x == 120 )
21389 //!( y>32 && (x!=120) ))
21390 {
21391
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 1 times.
118 switch ( dir )
21392 {
21393 case up:
21394 case r_up:
21395 case l_up:
21396 {
21397 117 di = nextscr(up);
21398
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 26 times.
117 if(tmpscr->door[0]==dLOCKED)
21399 {
21400
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 3 times.
91 if(usekey())
21401 {
21402 88 putdoor(scrollbuf,0,up,dUNLOCKED);
21403 88 tmpscr->door[0]=dUNLOCKED;
21404 88 setmapflag(si, mDOOR_UP);
21405
21406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(di != 0xFFFF)
21407 88 setmapflag(di, mDOOR_DOWN);
21408 88 sfx(WAV_DOOR);
21409 88 markBmap(-1);
21410 88 }
21411 3 else return;
21412 88 }
21413
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 15 times.
26 else if(tmpscr->door[0]==dBOSS)
21414 {
21415
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if(game->lvlitems[dlevel]&liBOSSKEY)
21416 {
21417 14 putdoor(scrollbuf,0,up,dOPENBOSS);
21418 14 tmpscr->door[0]=dOPENBOSS;
21419 14 setmapflag(si, mDOOR_UP);
21420
21421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(di != 0xFFFF)
21422 14 setmapflag(di, mDOOR_DOWN);
21423 14 sfx(WAV_DOOR);
21424 14 markBmap(-1);
21425 // Run Boss Key Script
21426 14 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 for ( int32_t q = 0; q < MAXITEMS; ++q )
21428 {
21429
2/2
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
952 if ( itemsbuf[q].family == itype_bosskey )
21430 {
21431 14 key_item = q; break;
21432 }
21433 938 }
21434
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21435 {
21436 ri = &(itemScriptData[key_item]);
21437 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21438 ri->Clear();
21439 item_doscript[key_item] = 1;
21440 itemscriptInitialised[key_item] = 0;
21441 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21442 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21443 }
21444 14 }
21445 1 else return;
21446 14 }
21447 113 break;
21448 }
21449 1 default: break;
21450
21451 }
21452 114 }
21453 //Down
21454
4/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 820 times.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 38 times.
939 if ( y >= 128 && x == 120 )
21455 //!(y<128 && (x!=120) ) )
21456 {
21457
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 3 times.
38 switch(dir)
21458 {
21459 case down:
21460 case l_down:
21461 case r_down:
21462 {
21463 35 di = nextscr(down);
21464
21465
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 11 times.
35 if(tmpscr->door[1]==dLOCKED)
21466 {
21467
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if(usekey())
21468 {
21469 23 putdoor(scrollbuf,0,down,dUNLOCKED);
21470 23 tmpscr->door[1]=dUNLOCKED;
21471 23 setmapflag(si, mDOOR_DOWN);
21472
21473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(di != 0xFFFF)
21474 23 setmapflag(di, mDOOR_UP);
21475 23 sfx(WAV_DOOR);
21476 23 markBmap(-1);
21477 23 }
21478 1 else return;
21479 23 }
21480
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 else if(tmpscr->door[1]==dBOSS)
21481 {
21482
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
21483 {
21484 4 putdoor(scrollbuf,0,down,dOPENBOSS);
21485 4 tmpscr->door[1]=dOPENBOSS;
21486 4 setmapflag(si, mDOOR_DOWN);
21487
21488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
21489 4 setmapflag(di, mDOOR_UP);
21490 4 sfx(WAV_DOOR);
21491 4 markBmap(-1);
21492 // Run Boss Key Script
21493 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
21495 {
21496
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
21497 {
21498 4 key_item = q; break;
21499 }
21500 268 }
21501
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21502 {
21503 ri = &(itemScriptData[key_item]);
21504 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21505 ri->Clear();
21506 item_doscript[key_item] = 1;
21507 itemscriptInitialised[key_item] = 0;
21508 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21509 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21510 }
21511 4 }
21512 1 else return;
21513 4 }
21514 33 break;
21515 }
21516 3 default: break;
21517 }
21518 36 }
21519 //left
21520
4/4
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 749 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 58 times.
937 if ( y == 80 && x <= 32 )
21521 //!( (y!=80) && x>32 ) )
21522 {
21523
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 9 times.
58 switch(dir)
21524 {
21525 case left:
21526 case l_up:
21527 case l_down:
21528 {
21529 49 di = nextscr(left);
21530
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 14 times.
49 if(tmpscr->door[2]==dLOCKED)
21531 {
21532
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2 times.
35 if(usekey())
21533 {
21534 33 putdoor(scrollbuf,0,left,dUNLOCKED);
21535 33 tmpscr->door[2]=dUNLOCKED;
21536 33 setmapflag(si, mDOOR_LEFT);
21537
21538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(di != 0xFFFF)
21539 33 setmapflag(di, mDOOR_RIGHT);
21540 33 sfx(WAV_DOOR);
21541 33 markBmap(-1);
21542 33 }
21543 2 else return;
21544 33 }
21545
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
14 else if(tmpscr->door[2]==dBOSS)
21546 {
21547
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
21548 {
21549 4 putdoor(scrollbuf,0,left,dOPENBOSS);
21550 4 tmpscr->door[2]=dOPENBOSS;
21551 4 setmapflag(si, mDOOR_LEFT);
21552
21553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
21554 4 setmapflag(di, mDOOR_RIGHT);
21555 4 sfx(WAV_DOOR);
21556 4 markBmap(-1);
21557 // Run Boss Key Script
21558 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
21560 {
21561
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
21562 {
21563 4 key_item = q; break;
21564 }
21565 268 }
21566
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
21567 {
21568 ri = &(itemScriptData[key_item]);
21569 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21570 ri->Clear();
21571 item_doscript[key_item] = 1;
21572 itemscriptInitialised[key_item] = 0;
21573 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21574 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21575 }
21576 4 }
21577 1 else return;
21578 4 }
21579
21580 46 break;
21581
21582 }
21583 9 default: break;
21584 }
21585 55 }
21586 //right
21587
4/4
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 749 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 73 times.
934 if ( y == 80 && x >= 208 )
21588 //!((y!=80) && x<208 ) )
21589 {
21590
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 4 times.
73 switch(dir)
21591 {
21592 case right:
21593 case r_down:
21594 case r_up:
21595 {
21596 69 di = nextscr(right);
21597
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 19 times.
69 if(tmpscr->door[3]==dLOCKED)
21598 {
21599
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 4 times.
50 if(usekey())
21600 {
21601 46 putdoor(scrollbuf,0,right,dUNLOCKED);
21602 46 tmpscr->door[3]=dUNLOCKED;
21603 46 setmapflag(si, mDOOR_RIGHT);
21604
21605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(di != 0xFFFF)
21606 46 setmapflag(di, mDOOR_LEFT);
21607 46 sfx(WAV_DOOR);
21608 46 markBmap(-1);
21609 46 }
21610 4 else return;
21611 46 }
21612
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 8 times.
19 else if(tmpscr->door[3]==dBOSS)
21613 {
21614
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(game->lvlitems[dlevel]&liBOSSKEY)
21615 {
21616 7 putdoor(scrollbuf,0,right,dOPENBOSS);
21617 7 tmpscr->door[3]=dOPENBOSS;
21618 7 setmapflag(si, mDOOR_RIGHT);
21619
21620
21621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(di != 0xFFFF)
21622 7 setmapflag(di, mDOOR_LEFT);
21623 7 sfx(WAV_DOOR);
21624 7 markBmap(-1);
21625 // Run Boss Key Script
21626 7 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 for ( int32_t q = 0; q < MAXITEMS; ++q )
21628 {
21629
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 7 times.
476 if ( itemsbuf[q].family == itype_bosskey )
21630 {
21631 7 key_item = q; break;
21632 }
21633 469 }
21634
2/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //
21635 {
21636 ri = &(itemScriptData[key_item]);
21637 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
21638 ri->Clear();
21639 item_doscript[key_item] = 1;
21640 itemscriptInitialised[key_item] = 0;
21641 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
21642 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
21643 }
21644
21645 7 }
21646 1 else return;
21647 7 }
21648
21649
21650 64 break;
21651 }
21652 4 default: break;
21653
21654 }
21655 68 }
21656 }
21657 6407879 }
21658
21659 6407879 void HeroClass::checkswordtap()
21660 {
21661
6/6
✓ Branch 0 taken 3024877 times.
✓ Branch 1 taken 3383002 times.
✓ Branch 2 taken 1913 times.
✓ Branch 3 taken 3022964 times.
✓ Branch 4 taken 1902 times.
✓ Branch 5 taken 11 times.
6407879 if(attack!=wSword || charging<=0 || pushing<8) return;
21662
21663 11 int32_t bx=x;
21664 11 int32_t by=y+8;
21665
21666
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
11 switch(dir)
21667 {
21668 case up:
21669
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!Up()) return;
21670
21671 11 by-=16;
21672 11 break;
21673
21674 case down:
21675 if(!Down()) return;
21676
21677 by+=16;
21678 bx+=8;
21679 break;
21680
21681 case left:
21682 if(!Left()) return;
21683
21684 bx-=16;
21685 by+=8;
21686 break;
21687
21688 case right:
21689 if(!Right()) return;
21690
21691 bx+=16;
21692 by+=8;
21693 break;
21694 }
21695
21696
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
11 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
21697
21698 11 attackclk=SWORDTAPFRAME;
21699 11 pushing=-8; //16 frames between taps
21700 11 tapping=true;
21701
21702 11 int32_t type = COMBOTYPE(bx,by);
21703
21704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!isCuttableType(type))
21705 {
21706
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
22 bool hollow = (MAPFLAG(bx,by) == mfBOMB || MAPCOMBOFLAG(bx,by) == mfBOMB ||
21707
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 MAPFLAG(bx,by) == mfSBOMB || MAPCOMBOFLAG(bx,by) == mfSBOMB);
21708
21709 // Layers
21710
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11 times.
77 for(int32_t i=0; i < 6; i++)
21711
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
132 hollow = (hollow || MAPFLAG2(i,bx,by) == mfBOMB || MAPCOMBOFLAG2(i,bx,by) == mfBOMB ||
21712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 MAPFLAG2(i,bx,by) == mfSBOMB || MAPCOMBOFLAG2(i,bx,by) == mfSBOMB);
21713
21714
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
21715
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if(tmpscr->door[i]==dBOMB && i==dir)
21716 switch(i)
21717 {
21718 case up:
21719 case down:
21720 if(bx>=112 && bx<144 && (by>=144 || by<=32)) hollow=true;
21721
21722 break;
21723
21724 case left:
21725 case right:
21726 if(by>=72 && by<104 && (bx>=224 || bx<=32)) hollow=true;
21727
21728 break;
21729 }
21730
21731 11 sfx(hollow ? WAV_ZN1TAP2 : WAV_ZN1TAP,pan(x.getInt()));
21732 11 }
21733
21734 6407879 }
21735
21736 19620 void HeroClass::fairycircle(int32_t type)
21737 {
21738
2/2
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 3259 times.
19620 if(fairyclk==0)
21739 {
21740
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3259 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3259 switch(type)
21741 {
21742 case REFILL_LIFE:
21743
2/2
✓ Branch 0 taken 3156 times.
✓ Branch 1 taken 103 times.
3259 if(didstuff&did_fairy) return;
21744
21745 103 didstuff|=did_fairy;
21746 103 break;
21747
21748 case REFILL_MAGIC:
21749 if(didstuff&did_magic) return;
21750
21751 didstuff|=did_magic;
21752 break;
21753
21754 case REFILL_ALL:
21755 if(didstuff&did_all) return;
21756
21757 didstuff|=did_all;
21758 }
21759
21760 103 refill_what=type;
21761 103 refill_why=REFILL_FAIRY;
21762 103 StartRefill(type);
21763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
21764 103 else {action=freeze; FFCore.setHeroAction(freeze);}
21765 103 holdclk=0;
21766 103 hopclk=0;
21767 103 }
21768
21769 16464 ++fairyclk;
21770
21771
2/2
✓ Branch 0 taken 8121 times.
✓ Branch 1 taken 8343 times.
16464 if(refilling!=REFILL_FAIRYDONE)
21772 {
21773
2/2
✓ Branch 0 taken 8018 times.
✓ Branch 1 taken 103 times.
8121 if(!refill())
21774 103 refilling=REFILL_FAIRYDONE;
21775 8121 }
21776
21777
2/2
✓ Branch 0 taken 8240 times.
✓ Branch 1 taken 103 times.
8343 else if(++holdclk>80)
21778 {
21779 103 reset_swordcharge();
21780 103 attackclk=0;
21781 103 action=none; FFCore.setHeroAction(none);
21782 103 fairyclk=0;
21783 103 holdclk=0;
21784 103 refill_why = 0;
21785 103 refilling=REFILL_NONE;
21786 103 map_bkgsfx(true);
21787 103 }
21788 19620 }
21789
21790 643354 int32_t touchcombo(int32_t x,int32_t y)
21791 {
21792
2/2
✓ Branch 0 taken 1286708 times.
✓ Branch 1 taken 643354 times.
1930062 for (int32_t i = 0; i <= 1; ++i)
21793 {
21794
2/2
✓ Branch 0 taken 1081023 times.
✓ Branch 1 taken 205685 times.
1286708 if(tmpscr2[i].valid!=0)
21795 {
21796
2/2
✓ Branch 0 taken 197733 times.
✓ Branch 1 taken 7952 times.
205685 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
21797 {
21798
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 197733 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
197733 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
21799 197733 }
21800 else
21801 {
21802
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7952 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7952 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
21803 }
21804 205685 }
21805 1286708 }
21806
2/2
✓ Branch 0 taken 641940 times.
✓ Branch 1 taken 1414 times.
643354 if (!_effectflag(x,y,1, -1)) return 0;
21807 641940 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
21808
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 641892 times.
641940 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
21809 48 return 0;
21810
3/3
✓ Branch 0 taken 2842 times.
✓ Branch 1 taken 637431 times.
✓ Branch 2 taken 1619 times.
641892 switch(cmb.type)
21811 {
21812 case cBSGRAVE:
21813 case cGRAVE:
21814
3/4
✓ Branch 0 taken 1913 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 1913 times.
✗ Branch 3 not taken.
2842 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
21815 {
21816 929 break;
21817 }
21818
21819 [[fallthrough]];
21820 case cARMOS:
21821 {
21822 3532 return cmb.type;
21823 }
21824 }
21825
21826 638360 return 0;
21827 643354 }
21828
21829 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
21830 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
21831
21832 static int32_t GridX(int32_t x)
21833 {
21834 return (x >> 4) << 4;
21835 }
21836
21837 //Snaps 'y' to the combo grid
21838 //Equivalent to calling ComboY(ComboAt(foo,y));
21839 static int32_t GridY(int32_t y)
21840 {
21841 return (y >> 4) << 4;
21842 }
21843
21844 30 int32_t grabComboFromPos(int32_t pos, int32_t type)
21845 {
21846
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 for(int32_t lyr = 6; lyr > -1; --lyr)
21847 {
21848 210 int32_t id = FFCore.tempScreens[lyr]->data[pos];
21849
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 180 times.
210 if(combobuf[id].type == type)
21850 30 return id;
21851 180 }
21852 return -1;
21853 30 }
21854
21855 static int32_t typeMap[176];
21856 static int32_t istrig[176];
21857 static const int32_t SPTYPE_SOLID = -1;
21858 #define SP_VISITED 0x1
21859 #define SPFLAG(dir) (0x2<<dir)
21860 #define BEAM_AGE_LIMIT 32
21861 1234 void HeroClass::handleBeam(byte* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
21862 {
21863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = set ? (1 << (set-1)) : ~0;
21864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(spotdir > 3) return; //invalid dir
21865 1234 bool doAge = true;
21866 1234 byte f = 0;
21867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13668 times.
13668 while(unsigned(curpos) < 176)
21868 {
21869 13668 bool block_light = false;
21870 13668 f = SPFLAG(spotdir);
21871
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 13341 times.
13668 if((grid[curpos] & f) != f)
21872 {
21873 13341 grid[curpos] |= f;
21874 13341 istrig[curpos] |= trigflag;
21875 13341 doAge = false;
21876 13341 age = 0;
21877 13341 }
21878
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 652 times.
✓ Branch 3 taken 12657 times.
✓ Branch 4 taken 183 times.
13668 switch(spotdir)
21879 {
21880 case up:
21881 176 curpos -= 0x10;
21882 176 break;
21883 case down:
21884 652 curpos += 0x10;
21885 652 break;
21886 case left:
21887
1/2
✓ Branch 0 taken 12657 times.
✗ Branch 1 not taken.
12657 if(!(curpos%0x10))
21888 curpos = -1;
21889 12657 else --curpos;
21890 12657 break;
21891 case right:
21892 183 ++curpos;
21893
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 if(!(curpos%0x10))
21894 curpos = -1;
21895 183 break;
21896 }
21897
1/2
✓ Branch 0 taken 13668 times.
✗ Branch 1 not taken.
13668 if(unsigned(curpos) >= 176) break;
21898
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 12440 times.
13668 switch(typeMap[curpos])
21899 {
21900 case SPTYPE_SOLID: case cBLOCKALL:
21901 1228 curpos = -1;
21902 1228 break;
21903 }
21904
3/6
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 13371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13668 if((curpos==COMBOPOS(x.getInt()+8,y.getInt()+8)) && block && (spotdir == oppositeDir[dir]))
21905 curpos = -1;
21906
2/2
✓ Branch 0 taken 12440 times.
✓ Branch 1 taken 1228 times.
13668 if(unsigned(curpos) >= 176) break;
21907
21908 12440 f = SPFLAG(oppositeDir[spotdir]);
21909
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 12113 times.
12440 if((grid[curpos] & f) != f)
21910 {
21911 12113 grid[curpos] |= f;
21912 12113 istrig[curpos] |= trigflag;
21913 12113 doAge = false;
21914 12113 age = 0;
21915 12113 }
21916
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 12113 times.
12440 if(doAge)
21917 {
21918
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 6 times.
327 if(++age > BEAM_AGE_LIMIT)
21919 6 break;
21920 321 }
21921 12113 else doAge = true;
21922
21923
3/4
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 12137 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
12434 if(curpos==COMBOPOS(x.getInt()+8,y.getInt() +8) && refl)
21924 297 spotdir = dir;
21925
2/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 12107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
12137 else switch(typeMap[curpos])
21926 {
21927 case cLIGHTTARGET:
21928
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(combobuf[grabComboFromPos(curpos, cLIGHTTARGET)].usrflags&cflag3) //Blocks light
21929 return;
21930 case cMIRROR:
21931 30 spotdir = oppositeDir[spotdir];
21932 30 break;
21933 case cMIRRORSLASH:
21934 switch(spotdir)
21935 {
21936 case up:
21937 spotdir = right; break;
21938 case right:
21939 spotdir = up; break;
21940 case down:
21941 spotdir = left; break;
21942 case left:
21943 spotdir = down; break;
21944 }
21945 break;
21946 case cMIRRORBACKSLASH:
21947 switch(spotdir)
21948 {
21949 case up:
21950 spotdir = left; break;
21951 case left:
21952 spotdir = up; break;
21953 case down:
21954 spotdir = right; break;
21955 case right:
21956 spotdir = down; break;
21957 }
21958 break;
21959 case cMAGICPRISM:
21960 for(byte d = 0; d < 4; ++d)
21961 {
21962 if(d == oppositeDir[spotdir]) continue;
21963 handleBeam(grid, age, d, curpos, set, block, refl);
21964 }
21965 return;
21966 case cMAGICPRISM4:
21967 for(byte d = 0; d < 4; ++d)
21968 {
21969 handleBeam(grid, age, d, curpos, set, block, refl);
21970 }
21971 return;
21972 }
21973 }
21974 1234 }
21975
21976 6418199 void HeroClass::handleSpotlights()
21977 {
21978 typedef byte spot_t;
21979 //Store each different tile/color as grids
21980 6418199 std::map<int32_t, spot_t*> maps;
21981
1/2
✓ Branch 0 taken 6418199 times.
✗ Branch 1 not taken.
6418199 int32_t shieldid = getCurrentShield(false);
21982
2/2
✓ Branch 0 taken 5876174 times.
✓ Branch 1 taken 542025 times.
6418199 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
21983
4/4
✓ Branch 0 taken 6408109 times.
✓ Branch 1 taken 10090 times.
✓ Branch 2 taken 542025 times.
✓ Branch 3 taken 5866084 times.
6418199 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
21984
3/6
✓ Branch 0 taken 6418199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6418199 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6418199 times.
✗ Branch 5 not taken.
6418199 int32_t heropos = COMBOPOS(x.getInt()+8,y.getInt()+8);
21985 6418199 memset(istrig, 0, sizeof(istrig));
21986
1/2
✓ Branch 0 taken 6418199 times.
✗ Branch 1 not taken.
6418199 clear_bitmap(lightbeam_bmp);
21987
21988
2/2
✓ Branch 0 taken 1129603024 times.
✓ Branch 1 taken 6418199 times.
1136021223 for(size_t pos = 0; pos < 176; ++pos)
21989 {
21990 1129603024 typeMap[pos] = 0;
21991
2/2
✓ Branch 0 taken 1129389548 times.
✓ Branch 1 taken 7907180560 times.
9036570108 for(int32_t lyr = 6; lyr > -1; --lyr)
21992 {
21993 7907180560 newcombo const* cmb = &combobuf[FFCore.tempScreens[lyr]->data[pos]];
21994
3/3
✓ Branch 0 taken 209774 times.
✓ Branch 1 taken 7906967084 times.
✓ Branch 2 taken 3702 times.
7907180560 switch(cmb->type)
21995 {
21996 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
21997 case cMAGICPRISM: case cMAGICPRISM4:
21998 case cBLOCKALL: case cLIGHTTARGET:
21999 209774 typeMap[pos] = cmb->type;
22000 209774 break;
22001 case cGLASS:
22002 3702 typeMap[pos] = 0;
22003 3702 break;
22004 default:
22005 {
22006
4/4
✓ Branch 0 taken 3388554988 times.
✓ Branch 1 taken 4518412096 times.
✓ Branch 2 taken 2706888200 times.
✓ Branch 3 taken 681666788 times.
7906967084 if(lyr < 3 && (cmb->walk & 0xF))
22007 {
22008 681666788 typeMap[pos] = SPTYPE_SOLID;
22009 681666788 }
22010 7906967084 continue; //next layer
22011 }
22012 }
22013 213476 break; //hit a combo type
22014 }
22015 1129603024 }
22016
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 6417952 times.
6418199 if(unsigned(heropos) < 176)
22017 {
22018
2/2
✓ Branch 0 taken 627557 times.
✓ Branch 1 taken 5790395 times.
6417952 switch(typeMap[heropos])
22019 {
22020 case SPTYPE_SOLID: case cBLOCKALL:
22021 627557 heropos = -1; //Blocked from hitting player
22022 627557 }
22023 6417952 }
22024
22025
2/2
✓ Branch 0 taken 44927393 times.
✓ Branch 1 taken 6418199 times.
51345592 for(size_t layer = 0; layer < 7; ++layer)
22026 {
22027 44927393 mapscr* curlayer = FFCore.tempScreens[layer];
22028
2/2
✓ Branch 0 taken 7907221168 times.
✓ Branch 1 taken 44927393 times.
7952148561 for(size_t pos = 0; pos < 176; ++pos)
22029 {
22030 //For each spotlight combo on each layer...
22031 7907221168 newcombo const& cmb = combobuf[curlayer->data[pos]];
22032
2/2
✓ Branch 0 taken 7907219934 times.
✓ Branch 1 taken 1234 times.
7907221168 if(cmb.type == cSPOTLIGHT)
22033 {
22034 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
22035
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
2468 int32_t id = (cmb.usrflags&cflag1)
22036
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 ? std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24
22037 : -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
22038
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(!id) continue;
22039 // zprint2("ID = %ld\n", id);
22040 //Get the grid array for this tile/color
22041 spot_t* grid;
22042
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1234 times.
1234 if(maps[id])
22043 grid = maps[id];
22044 else
22045 {
22046
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 grid = new spot_t[176];
22047 1234 memset(grid, 0, sizeof(spot_t)*176);
22048
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 maps[id] = grid;
22049 }
22050 1234 byte spotdir = cmb.attribytes[0];
22051 1234 int32_t curpos = pos;
22052
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(spotdir > 3)
22053 {
22054 grid[curpos] |= SP_VISITED;
22055 istrig[curpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
22056 }
22057
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1234 times.
✗ Branch 3 not taken.
1234 if(refl && curpos == heropos)
22058 {
22059 spotdir = dir;
22060 }
22061
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 handleBeam(grid, 0, spotdir, curpos, cmb.attribytes[4], block, refl);
22062 1234 }
22063 7907221168 }
22064 44927393 }
22065
22066 6418199 lightbeam_present = !maps.empty();
22067
22068 //Draw visuals
22069
2/2
✓ Branch 0 taken 6418199 times.
✓ Branch 1 taken 1234 times.
6419433 for(auto it = maps.begin(); it != maps.end();)
22070 {
22071 1234 int32_t id = it->first;
22072 1234 spot_t* grid = it->second;
22073 //
22074 enum {t_gr, t_up, t_down, t_left, t_right, t_uleft, t_uright, t_dleft, t_dright, t_vert, t_horz, t_notup, t_notdown, t_notleft, t_notright, t_all, t_max };
22075 1234 int32_t tile = (id&0xFFFFFF);
22076 1234 int32_t cs = (id>>24);
22077 1234 byte c_inner = ((-id)&0x0000FF);
22078 1234 byte c_middle = ((-id)&0x00FF00)>>8;
22079 1234 byte c_outter = ((-id)&0xFF0000)>>16;
22080 //{ Setup color bitmap
22081 1234 BITMAP* cbmp = NULL;
22082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(id < 0)
22083 {
22084 //zprint2("Creating with colors: %02X,%02X,%02X\n", c_inner, c_middle, c_outter);
22085 cbmp = create_bitmap_ex(8, 16*t_max, 16);
22086 clear_bitmap(cbmp);
22087 for(size_t q = 1; q < t_max; ++q)
22088 {
22089 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
22090 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
22091 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
22092 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
22093 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
22094 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
22095 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
22096 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
22097 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
22098 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
22099 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
22100 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
22101 }
22102 //t_gr
22103 circlefill(cbmp, 16*t_gr+8, 8, 7, c_outter);
22104 circlefill(cbmp, 16*t_gr+7, 8, 7, c_outter);
22105 circlefill(cbmp, 16*t_gr+8, 7, 7, c_outter);
22106 circlefill(cbmp, 16*t_gr+7, 7, 7, c_outter);
22107 circlefill(cbmp, 16*t_gr+8, 8, 5, c_middle);
22108 circlefill(cbmp, 16*t_gr+7, 8, 5, c_middle);
22109 circlefill(cbmp, 16*t_gr+8, 7, 5, c_middle);
22110 circlefill(cbmp, 16*t_gr+7, 7, 5, c_middle);
22111 circlefill(cbmp, 16*t_gr+8, 8, 3, c_inner);
22112 circlefill(cbmp, 16*t_gr+7, 8, 3, c_inner);
22113 circlefill(cbmp, 16*t_gr+8, 7, 3, c_inner);
22114 circlefill(cbmp, 16*t_gr+7, 7, 3, c_inner);
22115 //t_up
22116 rectfill(cbmp, 16*t_up+4, 0, 16*t_up+11, 7, c_outter);
22117 rectfill(cbmp, 16*t_up+6, 0, 16*t_up+9, 7, c_middle);
22118 rectfill(cbmp, 16*t_up+7, 0, 16*t_up+8, 7, c_inner);
22119 //t_down
22120 rectfill(cbmp, 16*t_down+4, 8, 16*t_down+11, 15, c_outter);
22121 rectfill(cbmp, 16*t_down+6, 8, 16*t_down+9, 15, c_middle);
22122 rectfill(cbmp, 16*t_down+7, 8, 16*t_down+8, 15, c_inner);
22123 //t_left
22124 rectfill(cbmp, 16*t_left, 4, 16*t_left+7, 11, c_outter);
22125 rectfill(cbmp, 16*t_left, 6, 16*t_left+7, 9, c_middle);
22126 rectfill(cbmp, 16*t_left, 7, 16*t_left+7, 8, c_inner);
22127 //t_right
22128 rectfill(cbmp, 16*t_right+8, 4, 16*t_right+15, 11, c_outter);
22129 rectfill(cbmp, 16*t_right+8, 6, 16*t_right+15, 9, c_middle);
22130 rectfill(cbmp, 16*t_right+8, 7, 16*t_right+15, 8, c_inner);
22131 //t_uleft
22132 rectfill(cbmp, 16*t_uleft+4, 0, 16*t_uleft+11, 7, c_outter);
22133 rectfill(cbmp, 16*t_uleft, 4, 16*t_uleft+7, 11, c_outter);
22134 rectfill(cbmp, 16*t_uleft, 6, 16*t_uleft+7, 9, c_middle);
22135 rectfill(cbmp, 16*t_uleft+6, 0, 16*t_uleft+9, 7, c_middle);
22136 rectfill(cbmp, 16*t_uleft+7, 0, 16*t_uleft+8, 7, c_inner);
22137 rectfill(cbmp, 16*t_uleft, 7, 16*t_uleft+7, 8, c_inner);
22138 //t_uright
22139 rectfill(cbmp, 16*t_uright+4, 0, 16*t_uright+11, 7, c_outter);
22140 rectfill(cbmp, 16*t_uright+8, 4, 16*t_uright+15, 11, c_outter);
22141 rectfill(cbmp, 16*t_uright+8, 6, 16*t_uright+15, 9, c_middle);
22142 rectfill(cbmp, 16*t_uright+6, 0, 16*t_uright+9, 7, c_middle);
22143 rectfill(cbmp, 16*t_uright+7, 0, 16*t_uright+8, 7, c_inner);
22144 rectfill(cbmp, 16*t_uright+8, 7, 16*t_uright+15, 8, c_inner);
22145 //t_dleft
22146 rectfill(cbmp, 16*t_dleft+4, 8, 16*t_dleft+11, 15, c_outter);
22147 rectfill(cbmp, 16*t_dleft, 4, 16*t_dleft+7, 11, c_outter);
22148 rectfill(cbmp, 16*t_dleft, 6, 16*t_dleft+7, 9, c_middle);
22149 rectfill(cbmp, 16*t_dleft+6, 8, 16*t_dleft+9, 15, c_middle);
22150 rectfill(cbmp, 16*t_dleft+7, 8, 16*t_dleft+8, 15, c_inner);
22151 rectfill(cbmp, 16*t_dleft, 7, 16*t_dleft+7, 8, c_inner);
22152 //t_dright
22153 rectfill(cbmp, 16*t_dright+4, 8, 16*t_dright+11, 15, c_outter);
22154 rectfill(cbmp, 16*t_dright+8, 4, 16*t_dright+15, 11, c_outter);
22155 rectfill(cbmp, 16*t_dright+8, 6, 16*t_dright+15, 9, c_middle);
22156 rectfill(cbmp, 16*t_dright+6, 8, 16*t_dright+9, 15, c_middle);
22157 rectfill(cbmp, 16*t_dright+7, 8, 16*t_dright+8, 15, c_inner);
22158 rectfill(cbmp, 16*t_dright+8, 7, 16*t_dright+15, 8, c_inner);
22159 //t_vert
22160 rectfill(cbmp, 16*t_vert+4, 0, 16*t_vert+11, 15, c_outter);
22161 rectfill(cbmp, 16*t_vert+6, 0, 16*t_vert+9, 15, c_middle);
22162 rectfill(cbmp, 16*t_vert+7, 0, 16*t_vert+8, 15, c_inner);
22163 //t_horz
22164 rectfill(cbmp, 16*t_horz, 4, 16*t_horz+15, 11, c_outter);
22165 rectfill(cbmp, 16*t_horz, 6, 16*t_horz+15, 9, c_middle);
22166 rectfill(cbmp, 16*t_horz, 7, 16*t_horz+15, 8, c_inner);
22167 //t_notup
22168 rectfill(cbmp, 16*t_notup, 4, 16*t_notup+15, 11, c_outter);
22169 rectfill(cbmp, 16*t_notup+4, 8, 16*t_notup+11, 15, c_outter);
22170 rectfill(cbmp, 16*t_notup+6, 8, 16*t_notup+9, 15, c_middle);
22171 rectfill(cbmp, 16*t_notup, 6, 16*t_notup+15, 9, c_middle);
22172 rectfill(cbmp, 16*t_notup, 7, 16*t_notup+15, 8, c_inner);
22173 rectfill(cbmp, 16*t_notup+7, 8, 16*t_notup+8, 15, c_inner);
22174 //t_notdown
22175 rectfill(cbmp, 16*t_notdown, 4, 16*t_notdown+15, 11, c_outter);
22176 rectfill(cbmp, 16*t_notdown+4, 0, 16*t_notdown+11, 7, c_outter);
22177 rectfill(cbmp, 16*t_notdown+6, 0, 16*t_notdown+9, 7, c_middle);
22178 rectfill(cbmp, 16*t_notdown, 6, 16*t_notdown+15, 9, c_middle);
22179 rectfill(cbmp, 16*t_notdown, 7, 16*t_notdown+15, 8, c_inner);
22180 rectfill(cbmp, 16*t_notdown+7, 0, 16*t_notdown+8, 7, c_inner);
22181 //t_notleft
22182 rectfill(cbmp, 16*t_notleft+4, 0, 16*t_notleft+11, 15, c_outter);
22183 rectfill(cbmp, 16*t_notleft+8, 4, 16*t_notleft+15, 11, c_outter);
22184 rectfill(cbmp, 16*t_notleft+8, 6, 16*t_notleft+15, 9, c_middle);
22185 rectfill(cbmp, 16*t_notleft+6, 0, 16*t_notleft+9, 15, c_middle);
22186 rectfill(cbmp, 16*t_notleft+7, 0, 16*t_notleft+8, 15, c_inner);
22187 rectfill(cbmp, 16*t_notleft+8, 7, 16*t_notleft+15, 8, c_inner);
22188 //t_notright
22189 rectfill(cbmp, 16*t_notright+4, 0, 16*t_notright+11, 15, c_outter);
22190 rectfill(cbmp, 16*t_notright, 4, 16*t_notright+7, 11, c_outter);
22191 rectfill(cbmp, 16*t_notright, 6, 16*t_notright+7, 9, c_middle);
22192 rectfill(cbmp, 16*t_notright+6, 0, 16*t_notright+9, 15, c_middle);
22193 rectfill(cbmp, 16*t_notright+7, 0, 16*t_notright+8, 15, c_inner);
22194 rectfill(cbmp, 16*t_notright, 7, 16*t_notright+7, 8, c_inner);
22195 //t_all
22196 rectfill(cbmp, 16*t_all+4, 0, 16*t_all+11, 15, c_outter);
22197 rectfill(cbmp, 16*t_all, 4, 16*t_all+15, 11, c_outter);
22198 rectfill(cbmp, 16*t_all, 6, 16*t_all+15, 9, c_middle);
22199 rectfill(cbmp, 16*t_all+6, 0, 16*t_all+9, 15, c_middle);
22200 rectfill(cbmp, 16*t_all+7, 0, 16*t_all+8, 15, c_inner);
22201 rectfill(cbmp, 16*t_all, 7, 16*t_all+15, 8, c_inner);
22202 }
22203 //}
22204 //
22205
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 217184 times.
218418 for(size_t pos = 0; pos < 176; ++pos)
22206 {
22207 217184 int32_t offs = -1;
22208
8/17
✗ Branch 0 not taken.
✓ Branch 1 taken 203837 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1207 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 511 times.
✓ Branch 7 taken 11477 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 37 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 82 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
217184 switch(grid[pos]>>1)
22209 {
22210 203837 case 0: default:
22211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203837 times.
203837 if(grid[pos])
22212 {
22213 offs = t_gr;
22214 break;
22215 }
22216 203837 continue; //no draw this pos
22217 case 0b0001:
22218 6 offs = t_up;
22219 6 break;
22220 case 0b0010:
22221 offs = t_down;
22222 break;
22223 case 0b0100:
22224 1207 offs = t_left;
22225 1207 break;
22226 case 0b1000:
22227 27 offs = t_right;
22228 27 break;
22229 case 0b0011:
22230 511 offs = t_vert;
22231 511 break;
22232 case 0b1100:
22233 11477 offs = t_horz;
22234 11477 break;
22235 case 0b0101:
22236 offs = t_uleft;
22237 break;
22238 case 0b1001:
22239 37 offs = t_uright;
22240 37 break;
22241 case 0b0110:
22242 offs = t_dleft;
22243 break;
22244 case 0b1010:
22245 82 offs = t_dright;
22246 82 break;
22247 case 0b1110:
22248 offs = t_notup;
22249 break;
22250 case 0b1101:
22251 offs = t_notdown;
22252 break;
22253 case 0b1011:
22254 offs = t_notleft;
22255 break;
22256 case 0b0111:
22257 offs = t_notright;
22258 break;
22259 case 0b1111:
22260 offs = t_all;
22261 break;
22262 }
22263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13347 times.
13347 if(id > 0) //tile
22264 {
22265 //Draw 'tile' at 'pos'
22266
3/6
✓ Branch 0 taken 13347 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13347 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13347 times.
✗ Branch 5 not taken.
13347 overtile16(lightbeam_bmp, tile+offs, COMBOX(pos), COMBOY(pos), cs, 0);
22267 13347 }
22268 else //colors
22269 {
22270 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
22271 }
22272 13347 }
22273 //
22274
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1234 if(cbmp) destroy_bitmap(cbmp);
22275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 delete[] it->second;
22276
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 it = maps.erase(it);
22277 }
22278 //Check triggers
22279 6418199 bool hastrigs = false, istrigged = true;
22280
1/2
✓ Branch 0 taken 6418199 times.
✗ Branch 1 not taken.
6418199 bool alltrig = getmapflag(mLIGHTBEAM);
22281
2/2
✓ Branch 0 taken 44927393 times.
✓ Branch 1 taken 6418199 times.
51345592 for(size_t layer = 0; layer < 7; ++layer)
22282 {
22283 44927393 mapscr* curlayer = FFCore.tempScreens[layer];
22284
2/2
✓ Branch 0 taken 7907221168 times.
✓ Branch 1 taken 44927393 times.
7952148561 for(size_t pos = 0; pos < 176; ++pos)
22285 {
22286 7907221168 newcombo const* cmb = &combobuf[curlayer->data[pos]];
22287
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 7907219934 times.
7907221168 if(cmb->type == cLIGHTTARGET)
22288 {
22289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
22290 1234 hastrigs = true;
22291 1234 bool trigged = (istrig[pos]&trigflag);
22292
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
22293 trigged = !trigged;
22294
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 985 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
22295 {
22296
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
22297 {
22298 curlayer->data[pos] -= 1;
22299 istrigged = false;
22300 }
22301 249 }
22302 else //Unsolved version
22303 {
22304
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
22305 1 curlayer->data[pos] += 1;
22306 984 else istrigged = false;
22307 }
22308 1234 }
22309
2/2
✓ Branch 0 taken 7907216232 times.
✓ Branch 1 taken 3702 times.
7907219934 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
22310 {
22311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
22312 3702 bool trigged = (istrig[pos]&trigflag);
22313
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 3597 times.
✓ Branch 2 taken 3696 times.
✓ Branch 3 taken 6 times.
3702 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
22314 3597 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
22315 {
22316
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 do_trigger_combo(layer, pos);
22317 6 }
22318 3702 }
22319 7907221168 }
22320 44927393 }
22321
1/2
✓ Branch 0 taken 6418199 times.
✗ Branch 1 not taken.
6418199 word c = tmpscr->numFFC();
22322
2/2
✓ Branch 0 taken 6418199 times.
✓ Branch 1 taken 201251546 times.
207669745 for(word i=0; i<c; i++)
22323 {
22324 201251546 ffcdata& ffc = tmpscr->ffcs[i];
22325
1/2
✓ Branch 0 taken 201251546 times.
✗ Branch 1 not taken.
201251546 newcombo const* cmb = &combobuf[ffc.getData()];
22326
7/14
✓ Branch 0 taken 201251546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201251546 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 201251546 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 201251546 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 201251546 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 201251546 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 201251546 times.
✗ Branch 13 not taken.
201251546 size_t pos = COMBOPOS(ffc.x+8, ffc.y+8);
22327
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 201250312 times.
201251546 if(cmb->type == cLIGHTTARGET)
22328 {
22329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
22330 1234 hastrigs = true;
22331 1234 bool trigged = (istrig[pos]&trigflag);
22332
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
22333 trigged = !trigged;
22334
2/2
✓ Branch 0 taken 985 times.
✓ Branch 1 taken 249 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
22335 {
22336
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
22337 {
22338 ffc.incData(-1);
22339 istrigged = false;
22340 }
22341 249 }
22342 else //Unsolved version
22343 {
22344
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
22345
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ffc.incData(1);
22346 984 else istrigged = false;
22347 }
22348 1234 }
22349
2/2
✓ Branch 0 taken 201247844 times.
✓ Branch 1 taken 2468 times.
201250312 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
22350 {
22351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2468 times.
2468 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
22352 2468 bool trigged = (istrig[pos]&trigflag);
22353
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2406 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2464 times.
2468 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
22354 2406 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
22355 {
22356
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 do_trigger_combo_ffc(i);
22357 4 }
22358 2468 }
22359 201251546 }
22360
6/6
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 6416965 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 984 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 249 times.
6418199 if(hastrigs && istrigged && !alltrig)
22361 {
22362
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 hidden_entrance(0,true,false,-7);
22363
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 sfx(tmpscr->secretsfx);
22364
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(tmpscr->flags5&fTEMPSECRETS))
22365 {
22366
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag(mSECRET);
22367
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag(mLIGHTBEAM);
22368 1 }
22369 1 }
22370 6418199 }
22371
22372 6407879 void HeroClass::checktouchblk()
22373 {
22374
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 6394473 times.
6407879 if(toogam) return;
22375
22376
2/2
✓ Branch 0 taken 441651 times.
✓ Branch 1 taken 5952822 times.
6394473 if(!pushing)
22377 5952822 return;
22378
22379 441651 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
22380
22381
4/4
✓ Branch 0 taken 441471 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 441375 times.
441651 if(charging > 0 || spins > 0) //if not I probably will at some point...
22382 {
22383
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 if(Up()&&Left())tdir = (charging%2)*2;
22384
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 else if(Up()&&Right())tdir = (charging%2)*3;
22385
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Left())tdir = 1+(charging%2)*1;
22386
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Right())tdir = 1+(charging%2)*2;
22387 else
22388 {
22389
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
276 if(Up())tdir=0;
22390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(Down())tdir=1;
22391
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(Left())tdir=2;
22392 else if(Right())tdir=3;
22393 }
22394 276 }
22395
22396 441651 int32_t tx=0,ty=-1;
22397
22398
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 109753 times.
✓ Branch 2 taken 93445 times.
✓ Branch 3 taken 114622 times.
✓ Branch 4 taken 123831 times.
441651 switch(tdir)
22399 {
22400 case up:
22401
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 109658 times.
109753 if(touchcombo(x,y+(bigHitbox?0:7)))
22402 {
22403 95 tx=x;
22404 95 ty=y+(bigHitbox?0:7);
22405 95 }
22406
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 109637 times.
109658 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
22407 {
22408 21 tx=x+8;
22409 21 ty=y+(bigHitbox?0:7);
22410 21 }
22411
22412 109753 break;
22413
22414 case down:
22415
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 92045 times.
93445 if(touchcombo(x,y+16))
22416 {
22417 1400 tx=x;
22418 1400 ty=y+16;
22419 1400 }
22420
2/2
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 91808 times.
92045 else if(touchcombo(x+8,y+16))
22421 {
22422 237 tx=x+8;
22423 237 ty=y+16;
22424 237 }
22425
22426 93445 break;
22427
22428 case left:
22429
2/2
✓ Branch 0 taken 113926 times.
✓ Branch 1 taken 696 times.
114622 if(touchcombo(x-1,y+15))
22430 {
22431 696 tx=x-1;
22432 696 ty=y+15;
22433 696 }
22434
22435 114622 break;
22436
22437 case right:
22438
2/2
✓ Branch 0 taken 122748 times.
✓ Branch 1 taken 1083 times.
123831 if(touchcombo(x+16,y+15))
22439 {
22440 1083 tx=x+16;
22441 1083 ty=y+15;
22442 1083 }
22443
22444 123831 break;
22445 }
22446
22447
2/2
✓ Branch 0 taken 438119 times.
✓ Branch 1 taken 3532 times.
441651 if(ty>=0)
22448 {
22449 3532 ty&=0xF0;
22450 3532 tx&=0xF0;
22451 3532 int32_t di = ty+(tx>>4);
22452
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3532 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3532 if((getAction() != hopping || isSideViewHero()))
22453 {
22454 3532 trigger_armos_grave(0, di, dir);
22455 3532 }
22456 3532 }
22457 6407879 }
22458
22459 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
22460 {
22461 switch(cdir)
22462 {
22463 case up:
22464 cy-=16;
22465 break;
22466
22467 case down:
22468 cy+=16;
22469 break;
22470
22471 case left:
22472 cx-=16;
22473 break;
22474
22475 case right:
22476 cx+=16;
22477 break;
22478 }
22479
22480 // off the screen
22481 if(cx<0 || cy<0 || cx>255 || cy>175)
22482 {
22483 int32_t ns = nextscr(cdir);
22484
22485 if(ns==0xFFFF) return 0;
22486
22487 // want actual screen index, not game->maps[] index
22488 ns = (ns&127) + (ns>>7)*MAPSCRS;
22489
22490 switch(cdir)
22491 {
22492 case up:
22493 cy=160;
22494 break;
22495
22496 case down:
22497 cy=0;
22498 break;
22499
22500 case left:
22501 cx=240;
22502 break;
22503
22504 case right:
22505 cx=0;
22506 break;
22507 }
22508
22509 // from MAPCOMBO()
22510 int32_t cmb = (cy&0xF0)+(cx>>4);
22511
22512 if(cmb>175)
22513 return 0;
22514
22515 return TheMaps[ns].data[cmb]; // entire combo code
22516 }
22517
22518 return MAPCOMBO(cx,cy);
22519 }
22520
22521 8492 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
22522 {
22523
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1729 times.
✓ Branch 2 taken 2005 times.
✓ Branch 3 taken 2441 times.
✓ Branch 4 taken 2317 times.
8492 switch(cdir)
22524 {
22525 case up:
22526 1729 cy-=16;
22527 1729 break;
22528
22529 case down:
22530 2005 cy+=16;
22531 2005 break;
22532
22533 case left:
22534 2441 cx-=16;
22535 2441 break;
22536
22537 case right:
22538 2317 cx+=16;
22539 2317 break;
22540 }
22541
22542 // off the screen
22543
8/8
✓ Branch 0 taken 8445 times.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 8386 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 8273 times.
✓ Branch 5 taken 113 times.
✓ Branch 6 taken 101 times.
✓ Branch 7 taken 8172 times.
8492 if(cx<0 || cy<0 || cx>255 || cy>175)
22544 {
22545 320 int32_t ns = nextscr(cdir);
22546
22547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(ns==0xFFFF) return 0;
22548
22549 // want actual screen index, not game->maps[] index
22550 320 ns = (ns&127) + (ns>>7)*MAPSCRS;
22551
22552
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 113 times.
320 switch(cdir)
22553 {
22554 case up:
22555 59 cy=160;
22556 59 break;
22557
22558 case down:
22559 101 cy=0;
22560 101 break;
22561
22562 case left:
22563 47 cx=240;
22564 47 break;
22565
22566 case right:
22567 113 cx=0;
22568 113 break;
22569 }
22570
22571 // from MAPCOMBO()
22572 320 int32_t cmb = (cy&0xF0)+(cx>>4);
22573
22574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(cmb>175)
22575 return 0;
22576
22577
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 255 times.
320 if(!comboflag)
22578 {
22579 255 return TheMaps[ns].sflag[cmb]; // flag
22580 }
22581 else
22582 {
22583 65 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
22584 }
22585 }
22586
22587
2/2
✓ Branch 0 taken 2006 times.
✓ Branch 1 taken 6166 times.
8172 if(comboflag)
22588 {
22589 2006 return MAPCOMBOFLAG(cx,cy);
22590 }
22591
22592 6166 return MAPFLAG(cx,cy);
22593 8492 }
22594
22595 bool did_secret;
22596
22597 6407879 void HeroClass::checkspecial()
22598 {
22599 6407879 checktouchblk();
22600
22601 6407879 bool hasmainguy = hasMainGuy(); // calculate it once
22602
22603
4/4
✓ Branch 0 taken 6340494 times.
✓ Branch 1 taken 67385 times.
✓ Branch 2 taken 4087880 times.
✓ Branch 3 taken 2252614 times.
6407879 if(!(loaded_enemies && !hasmainguy))
22604 4155265 did_secret=false;
22605 else
22606 {
22607 // after beating enemies
22608
22609 // generic 'Enemies->' trigger
22610
2/2
✓ Branch 0 taken 15768298 times.
✓ Branch 1 taken 2252614 times.
18020912 for(auto lyr = 0; lyr < 7; ++lyr)
22611 {
22612
2/2
✓ Branch 0 taken 2775220448 times.
✓ Branch 1 taken 15768298 times.
2790988746 for(auto pos = 0; pos < 176; ++pos)
22613 {
22614 2775220448 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
22615
2/2
✓ Branch 0 taken 2775220445 times.
✓ Branch 1 taken 3 times.
2775220448 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
22616 {
22617 3 do_trigger_combo(lyr,pos);
22618 3 }
22619 2775220448 }
22620 15768298 }
22621 2252614 word c = tmpscr->numFFC();
22622
2/2
✓ Branch 0 taken 69100347 times.
✓ Branch 1 taken 2252614 times.
71352961 for(word i=0; i<c; i++)
22623 {
22624 69100347 ffcdata& ffc = tmpscr->ffcs[i];
22625 69100347 newcombo const& cmb = combobuf[ffc.getData()];
22626
1/2
✓ Branch 0 taken 69100347 times.
✗ Branch 1 not taken.
69100347 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
22627 {
22628 do_trigger_combo_ffc(i);
22629 }
22630 69100347 }
22631
1/2
✓ Branch 0 taken 2252614 times.
✗ Branch 1 not taken.
2252614 if(tmpscr->flags9 & fENEMY_WAVES)
22632 {
22633 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
22634 }
22635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2252614 times.
2252614 if(!hasmainguy)
22636 {
22637 // item
22638
2/2
✓ Branch 0 taken 2252162 times.
✓ Branch 1 taken 452 times.
2252614 if(hasitem&(4|2|1))
22639 {
22640 452 int32_t Item=tmpscr->item;
22641
22642 //if(getmapflag())
22643 // Item=0;
22644
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 452 times.
452 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
22645 {
22646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
452 if(hasitem==1)
22647 452 sfx(WAV_CLEARED);
22648
22649
2/4
✓ Branch 0 taken 452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
904 items.add(new item((zfix)tmpscr->itemx,
22650
6/12
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 452 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 452 times.
✗ Branch 11 not taken.
452 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
22651
6/10
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 426 times.
✗ Branch 9 not taken.
452 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
22652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
452 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
22653 452 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
22654 452 }
22655
22656 452 hasitem &= ~ (4|2|1);
22657 452 }
22658 // if room has traps, guys don't come back
22659
2/2
✓ Branch 0 taken 1153338368 times.
✓ Branch 1 taken 2252614 times.
1155590982 for(int32_t i=0; i<eMAXGUYS; i++)
22660 {
22661
4/4
✓ Branch 0 taken 33530008 times.
✓ Branch 1 taken 1119808360 times.
✓ Branch 2 taken 29081986 times.
✓ Branch 3 taken 4448022 times.
1153338368 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
22662
4/4
✓ Branch 0 taken 22637 times.
✓ Branch 1 taken 4425385 times.
✓ Branch 2 taken 22611 times.
✓ Branch 3 taken 26 times.
4448048 if(guys.idCount(i) && !getmapflag(mTMPNORET))
22663 26 setmapflag(mTMPNORET);
22664 1153338368 }
22665 // clear enemies and open secret
22666
4/4
✓ Branch 0 taken 2136575 times.
✓ Branch 1 taken 116039 times.
✓ Branch 2 taken 2136124 times.
✓ Branch 3 taken 451 times.
2252614 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
22667 {
22668 451 bool only16_31 = get_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
22669 451 hidden_entrance(0,true,only16_31,-2);
22670
22671
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 427 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 19 times.
451 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
22672 {
22673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
22674 19 }
22675
22676 451 sfx(tmpscr->secretsfx);
22677 451 did_secret=true;
22678 451 }
22679 2252614 }
22680 }
22681
22682 // doors
22683 6407879 bool has_shutter = false;
22684
2/2
✓ Branch 0 taken 4987088 times.
✓ Branch 1 taken 23033728 times.
28020816 for(int32_t i=0; i<4; i++)
22685
2/2
✓ Branch 0 taken 21612937 times.
✓ Branch 1 taken 1420791 times.
23033728 if(tmpscr->door[i]==dSHUTTER)
22686 {
22687 1420791 has_shutter = true;
22688
4/4
✓ Branch 0 taken 1393331 times.
✓ Branch 1 taken 27460 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 1392416 times.
1420791 if(opendoors==0 && loaded_enemies)
22689 {
22690
4/4
✓ Branch 0 taken 1155712 times.
✓ Branch 1 taken 236704 times.
✓ Branch 2 taken 1154083 times.
✓ Branch 3 taken 1629 times.
1392416 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
22691 1629 opendoors=12;
22692 1392416 }
22693
2/2
✓ Branch 0 taken 22475 times.
✓ Branch 1 taken 5900 times.
28375 else if(opendoors<0)
22694 5900 ++opendoors;
22695
2/2
✓ Branch 0 taken 20594 times.
✓ Branch 1 taken 1881 times.
22475 else if((--opendoors)==0)
22696 1881 openshutters();
22697
22698 1420791 break;
22699 }
22700
10/10
✓ Branch 0 taken 4987088 times.
✓ Branch 1 taken 1420791 times.
✓ Branch 2 taken 4879925 times.
✓ Branch 3 taken 107163 times.
✓ Branch 4 taken 4817217 times.
✓ Branch 5 taken 62708 times.
✓ Branch 6 taken 4760435 times.
✓ Branch 7 taken 56782 times.
✓ Branch 8 taken 2701418 times.
✓ Branch 9 taken 2059017 times.
6407879 if(!has_shutter && !opendoors && loaded_enemies && !(tmpscr->flags&fSHUTTERS) && !hasmainguy)
22701 {
22702 2059017 openshutters();
22703 2059017 }
22704
22705 // set boss flag when boss is gone
22706
6/6
✓ Branch 0 taken 6340494 times.
✓ Branch 1 taken 67385 times.
✓ Branch 2 taken 113421 times.
✓ Branch 3 taken 6227073 times.
✓ Branch 4 taken 85999 times.
✓ Branch 5 taken 27422 times.
6407879 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
22707 {
22708 27422 game->lvlitems[dlevel]|=liBOSS;
22709 27422 stop_sfx(tmpscr->bosssfx);
22710 27422 }
22711
22712
2/2
✓ Branch 0 taken 6393580 times.
✓ Branch 1 taken 14299 times.
6407879 if(getmapflag(mCHEST)) // if special stuff done before
22713 {
22714 14299 remove_chests((currscr>=128)?1:0);
22715 14299 }
22716
22717
1/2
✓ Branch 0 taken 6407879 times.
✗ Branch 1 not taken.
6407879 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
22718 {
22719 remove_lockedchests((currscr>=128)?1:0);
22720 }
22721
22722
1/2
✓ Branch 0 taken 6407879 times.
✗ Branch 1 not taken.
6407879 if(getmapflag(mBOSSCHEST)) // if special stuff done before
22723 {
22724 remove_bosschests((currscr>=128)?1:0);
22725 }
22726
22727 6407879 clear_xstatecombos((currscr>=128)?1:0);
22728
22729
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6407879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6407879 if((hasitem&8) && triggered_screen_secrets)
22730 {
22731 int32_t Item=tmpscr->item;
22732
22733 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
22734 {
22735 items.add(new item((zfix)tmpscr->itemx,
22736 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
22737 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
22738 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
22739 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
22740 }
22741
22742 hasitem &= ~8;
22743 }
22744 6407879 }
22745
22746 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
22747 4399678 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
22748 {
22749 int32_t tmp;
22750 4399678 poses[0] = COMBOPOS(x1,y1);
22751
22752 4399678 tmp = COMBOPOS(x1,y2);
22753
2/2
✓ Branch 0 taken 3481199 times.
✓ Branch 1 taken 918479 times.
4399678 if(tmp == poses[0])
22754 3481199 poses[1] = -1;
22755 918479 else poses[1] = tmp;
22756
22757 4399678 tmp = COMBOPOS(x2,y1);
22758
3/4
✓ Branch 0 taken 1923953 times.
✓ Branch 1 taken 2475725 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1923953 times.
4399678 if(tmp == poses[0] || tmp == poses[1])
22759 2475725 poses[2] = -1;
22760 1923953 else poses[2] = tmp;
22761
22762 4399678 tmp = COMBOPOS(x2,y2);
22763
6/6
✓ Branch 0 taken 2466607 times.
✓ Branch 1 taken 1933071 times.
✓ Branch 2 taken 1923953 times.
✓ Branch 3 taken 542654 times.
✓ Branch 4 taken 1548128 times.
✓ Branch 5 taken 375825 times.
4399678 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
22764 4023853 poses[3] = -1;
22765 375825 else poses[3] = tmp;
22766 4399678 }
22767
22768 6403313 void HeroClass::checkspecial2(int32_t *ls)
22769 {
22770
6/8
✓ Branch 0 taken 5742512 times.
✓ Branch 1 taken 660801 times.
✓ Branch 2 taken 5691235 times.
✓ Branch 3 taken 51277 times.
✓ Branch 4 taken 5691235 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5691235 times.
6403313 if(get_bit(quest_rules,qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
22771 {
22772 // Must run fairycircle stuff if currently active, otherwise hero gets stuck!
22773
2/2
✓ Branch 0 taken 15761 times.
✓ Branch 1 taken 5675474 times.
5691235 if (!fairyclk)
22774 {
22775
2/2
✓ Branch 0 taken 1645947 times.
✓ Branch 1 taken 4029527 times.
5675474 if(y.getInt()&7)
22776 1645947 return;
22777
22778
2/2
✓ Branch 0 taken 2204063 times.
✓ Branch 1 taken 1825464 times.
4029527 if(x.getInt()&7)
22779 2204063 return;
22780 1825464 }
22781 1841225 }
22782
22783
2/2
✓ Branch 0 taken 4512 times.
✓ Branch 1 taken 2548791 times.
2553303 if(toogam) return;
22784
22785 2548791 bool didstrig = false;
22786
22787
2/2
✓ Branch 0 taken 5097247 times.
✓ Branch 1 taken 2548788 times.
7646035 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
22788 {
22789
4/4
✓ Branch 0 taken 10194494 times.
✓ Branch 1 taken 5097244 times.
✓ Branch 2 taken 20388985 times.
✓ Branch 3 taken 10194491 times.
35680720 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
22790 {
22791
2/2
✓ Branch 0 taken 10194491 times.
✓ Branch 1 taken 10194494 times.
20388985 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
22792 20388985 int32_t stype = cmb.type;
22793 20388985 int32_t warpsound = cmb.attribytes[0];
22794
2/2
✓ Branch 0 taken 20388783 times.
✓ Branch 1 taken 202 times.
20388985 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
22795 202 stype = cNONE;
22796
2/2
✓ Branch 0 taken 20388982 times.
✓ Branch 1 taken 3 times.
20388985 if(stype==cSWARPA)
22797 {
22798
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(tmpscr->flags5&fDIRECTSWARP)
22799 {
22800 didpit=true;
22801 pitx=x;
22802 pity=y;
22803 }
22804
22805 3 sdir=dir;
22806 3 dowarp(0,0,warpsound);
22807 3 return;
22808 }
22809
22810
1/2
✓ Branch 0 taken 20388982 times.
✗ Branch 1 not taken.
20388982 if(stype==cSWARPB)
22811 {
22812 if(tmpscr->flags5&fDIRECTSWARP)
22813 {
22814 didpit=true;
22815 pitx=x;
22816 pity=y;
22817 }
22818
22819 sdir=dir;
22820 dowarp(0,1,warpsound);
22821 return;
22822 }
22823
22824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20388982 times.
20388982 if(stype==cSWARPC)
22825 {
22826 if(tmpscr->flags5&fDIRECTSWARP)
22827 {
22828 didpit=true;
22829 pitx=x;
22830 pity=y;
22831 }
22832
22833 sdir=dir;
22834 dowarp(0,2,warpsound);
22835 return;
22836 }
22837
22838
1/2
✓ Branch 0 taken 20388982 times.
✗ Branch 1 not taken.
20388982 if(stype==cSWARPD)
22839 {
22840 if(tmpscr->flags5&fDIRECTSWARP)
22841 {
22842 didpit=true;
22843 pitx=x;
22844 pity=y;
22845 }
22846
22847 sdir=dir;
22848 dowarp(0,3,warpsound);
22849 return;
22850 }
22851
22852
1/2
✓ Branch 0 taken 20388982 times.
✗ Branch 1 not taken.
20388982 if(stype==cSWARPR)
22853 {
22854 if(tmpscr->flags5&fDIRECTSWARP)
22855 {
22856 didpit=true;
22857 pitx=x;
22858 pity=y;
22859 }
22860
22861 sdir=dir;
22862 dowarp(0,(zc_oldrand()%4),warpsound);
22863 return;
22864 }
22865
22866 20388982 int32_t pos = COMBOPOS(x+j, y+i);
22867
4/4
✓ Branch 0 taken 20386826 times.
✓ Branch 1 taken 2156 times.
✓ Branch 2 taken 20388272 times.
✓ Branch 3 taken 710 times.
20388982 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=pos)
22868 {
22869 // zprint("Step Secs\n");
22870
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710 if(stype==cSTRIGFLAG && canPermSecret())
22871 {
22872 if(!didstrig)
22873 {
22874 stepsecret = pos;
22875
22876 if(!(tmpscr->flags5&fTEMPSECRETS))
22877 {
22878 setmapflag(mSECRET);
22879 }
22880 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
22881 //zprint("Step Secrets SFX: %d\n", thesfx);
22882 sfx(warpsound,pan((int32_t)x));
22883 hidden_entrance(0,true,false);
22884 didstrig = true;
22885 }
22886 }
22887 else
22888 {
22889
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 345 times.
710 if(!didstrig)
22890 {
22891 345 stepsecret = pos;
22892 345 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
22893 345 hidden_entrance(0,true,only16_31);
22894 345 didstrig = true;
22895 //play trigger sound
22896 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
22897 //zprint("Step Secrets SFX: %d\n", thesfx);
22898 //sfx(thesfx,pan((int32_t)x));
22899 345 sfx(warpsound,pan((int32_t)x));
22900 345 }
22901 }
22902 710 }
22903 30583473 }
22904 5097244 }
22905
22906 2548788 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
22907
22908 // check if he's standing on a warp he just came out of
22909 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
22910
2/2
✓ Branch 0 taken 920014 times.
✓ Branch 1 taken 1628774 times.
2548788 if (!get_bit(quest_rules,qr_210_WARPRETURN))
22911 {
22912
6/6
✓ Branch 0 taken 1627447 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 191968 times.
✓ Branch 3 taken 1435479 times.
✓ Branch 4 taken 15329 times.
✓ Branch 5 taken 176639 times.
1628774 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
22913 {
22914
5/6
✓ Branch 0 taken 176018 times.
✓ Branch 1 taken 621 times.
✓ Branch 2 taken 175029 times.
✓ Branch 3 taken 989 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 175029 times.
176639 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
22915 {
22916
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 175024 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
175029 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
22917 175029 else return;
22918 }
22919 1610 }
22920 1453745 }
22921 else
22922 {
22923
2/2
✓ Branch 0 taken 761390 times.
✓ Branch 1 taken 158624 times.
920014 if((int(y)&0xF8)==warpy)
22924 {
22925
2/2
✓ Branch 0 taken 1380 times.
✓ Branch 1 taken 157244 times.
158624 if(x==warpx)
22926 {
22927
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 157244 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
157244 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
22928 157244 else return;
22929 }
22930 1380 }
22931 }
22932
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 2216349 times.
2216515 if (!RaftPass) warpy=-1;
22933
22934
6/6
✓ Branch 0 taken 2212978 times.
✓ Branch 1 taken 3205 times.
✓ Branch 2 taken 148327 times.
✓ Branch 3 taken 2064651 times.
✓ Branch 4 taken 110700 times.
✓ Branch 5 taken 37627 times.
2216515 if(((int32_t)y<raftwarpy-(get_bit(quest_rules, qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_bit(quest_rules, qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
22935 {
22936 2105483 raftwarpy = -1;
22937 2105483 }
22938
6/6
✓ Branch 0 taken 2213709 times.
✓ Branch 1 taken 2474 times.
✓ Branch 2 taken 130058 times.
✓ Branch 3 taken 2083651 times.
✓ Branch 4 taken 94780 times.
✓ Branch 5 taken 35278 times.
2216183 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
22939 {
22940 2121403 raftwarpx = -1;
22941 2121403 }
22942 2216183 int32_t tx=x;
22943 2216183 int32_t ty=y;
22944
22945 2216183 int32_t flag=0;
22946 2216183 int32_t flag2=0;
22947 2216183 int32_t flag3=0;
22948 2216183 int32_t type=0;
22949 2216183 int32_t water=0;
22950 2216183 int32_t index = 0;
22951
22952 2216183 bool setsave=false;
22953 2216183 int32_t warpsfx2 = 0;
22954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2216183 times.
2216183 if (RaftPass) goto RaftingStuff;
22955
22956 //bool gotpit=false;
22957
22958 int32_t x1,x2,y1,y2;
22959 2216183 x1 = tx;
22960 2216183 x2 = tx+15;
22961 2216183 y1 = ty;
22962 2216183 y2 = ty+15;
22963
22964
5/6
✓ Branch 0 taken 1553997 times.
✓ Branch 1 taken 662186 times.
✓ Branch 2 taken 1553997 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 166 times.
✓ Branch 5 taken 1554163 times.
2216183 if((diagonalMovement||NO_GRIDLOCK))
22965 {
22966 662352 x1 = tx+4;
22967 662352 x2 = tx+11;
22968 662352 y1 = ty+4;
22969 662352 y2 = ty+11;
22970 662352 }
22971
22972 int32_t types[4];
22973 2216515 types[0]=types[1]=types[2]=types[3]=-1;
22974 int32_t cids[4];
22975 int32_t ffcids[4];
22976 2216515 cids[0]=cids[1]=cids[2]=cids[3]=-1;
22977 2216515 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
22978 //
22979 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
22980 //
22981 2216515 types[0] = MAPFLAG(x1,y1);
22982 2216515 types[1] = MAPFLAG(x1,y2);
22983 2216515 types[2] = MAPFLAG(x2,y1);
22984 2216515 types[3] = MAPFLAG(x2,y2);
22985
22986
22987 //MAPFFCOMBO
22988
22989
22990
6/6
✓ Branch 0 taken 2168270 times.
✓ Branch 1 taken 48245 times.
✓ Branch 2 taken 2162570 times.
✓ Branch 3 taken 5700 times.
✓ Branch 4 taken 24748 times.
✓ Branch 5 taken 2137822 times.
2216515 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
22991 2137822 flag = types[0];
22992
22993 // 2.10 compatibility...
22994
8/10
✓ Branch 0 taken 48458 times.
✓ Branch 1 taken 30235 times.
✓ Branch 2 taken 40925 times.
✓ Branch 3 taken 7533 times.
✓ Branch 4 taken 29907 times.
✓ Branch 5 taken 11018 times.
✓ Branch 6 taken 29907 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 29907 times.
78693 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
22995 11018 flag = types[0];
22996
22997
22998 2216515 types[0] = MAPCOMBOFLAG(x1,y1);
22999 2216515 types[1] = MAPCOMBOFLAG(x1,y2);
23000 2216515 types[2] = MAPCOMBOFLAG(x2,y1);
23001 2216515 types[3] = MAPCOMBOFLAG(x2,y2);
23002
23003
6/6
✓ Branch 0 taken 2214419 times.
✓ Branch 1 taken 2096 times.
✓ Branch 2 taken 2214030 times.
✓ Branch 3 taken 389 times.
✓ Branch 4 taken 680 times.
✓ Branch 5 taken 2213350 times.
2216515 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23004 2213350 flag2 = types[0];
23005
23006 2216515 types[0] = MAPFFCOMBOFLAG(x1,y1);
23007 2216515 types[1] = MAPFFCOMBOFLAG(x1,y2);
23008 2216515 types[2] = MAPFFCOMBOFLAG(x2,y1);
23009 2216515 types[3] = MAPFFCOMBOFLAG(x2,y2);
23010
23011
23012 //
23013
23014
6/6
✓ Branch 0 taken 2216331 times.
✓ Branch 1 taken 184 times.
✓ Branch 2 taken 2216324 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2216320 times.
2216515 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23015 2216320 flag3 = types[0];
23016
23017 //
23018 // Now, let's check for warp combos...
23019 //
23020
23021 //
23022
23023 2216515 cids[0] = MAPCOMBO(x1,y1);
23024 2216515 cids[1] = MAPCOMBO(x1,y2);
23025 2216515 cids[2] = MAPCOMBO(x2,y1);
23026 2216515 cids[3] = MAPCOMBO(x2,y2);
23027
23028 2216515 types[0] = COMBOTYPE(x1,y1);
23029
23030
2/2
✓ Branch 0 taken 2193398 times.
✓ Branch 1 taken 23117 times.
2216515 if(MAPFFCOMBO(x1,y1))
23031 {
23032 23117 types[0] = FFCOMBOTYPE(x1,y1);
23033 23117 cids[0] = MAPFFCOMBO(x1,y1);
23034 23117 }
23035
23036 2216515 types[1] = COMBOTYPE(x1,y2);
23037
23038
2/2
✓ Branch 0 taken 2198561 times.
✓ Branch 1 taken 17954 times.
2216515 if(MAPFFCOMBO(x1,y2))
23039 {
23040 17954 types[1] = FFCOMBOTYPE(x1,y2);
23041 17954 cids[1] = MAPFFCOMBO(x1,y2);
23042 17954 }
23043
23044 2216515 types[2] = COMBOTYPE(x2,y1);
23045
23046
2/2
✓ Branch 0 taken 2193187 times.
✓ Branch 1 taken 23328 times.
2216515 if(MAPFFCOMBO(x2,y1))
23047 {
23048 23328 types[2] = FFCOMBOTYPE(x2,y1);
23049 23328 cids[2] = MAPFFCOMBO(x2,y1);
23050 23328 }
23051 2216515 types[3] = COMBOTYPE(x2,y2);
23052
23053
2/2
✓ Branch 0 taken 2198045 times.
✓ Branch 1 taken 18470 times.
2216515 if(MAPFFCOMBO(x2,y2))
23054 {
23055 18470 types[3] = FFCOMBOTYPE(x2,y2);
23056 18470 cids[3] = MAPFFCOMBO(x2,y2);
23057 18470 }
23058 // Change B, C and D warps into A, for the comparison below...
23059
2/2
✓ Branch 0 taken 8865396 times.
✓ Branch 1 taken 2216515 times.
11081911 for(int32_t i=0; i<4; i++)
23060 {
23061
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 8865072 times.
8865396 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23062 {
23063 324 types[i] = cNONE;
23064 324 continue;
23065 }
23066
2/2
✓ Branch 0 taken 2456 times.
✓ Branch 1 taken 8862616 times.
8865072 if(types[i]==cCAVE)
23067 {
23068 2456 index=0;
23069 2456 warpsfx2 = combobuf[cids[i]].attribytes[0];
23070 2456 }
23071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8862616 times.
8862616 else if(types[i]==cCAVEB)
23072 {
23073 types[i]=cCAVE;
23074 index=1;
23075 warpsfx2 = combobuf[cids[i]].attribytes[0];
23076 }
23077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8862616 times.
8862616 else if(types[i]==cCAVEC)
23078 {
23079 types[i]=cCAVE;
23080 index=2;
23081 warpsfx2 = combobuf[cids[i]].attribytes[0];
23082 }
23083
1/2
✓ Branch 0 taken 8862616 times.
✗ Branch 1 not taken.
8862616 else if(types[i]==cCAVED)
23084 {
23085 types[i]=cCAVE;
23086 index=3;
23087 warpsfx2 = combobuf[cids[i]].attribytes[0];
23088 }
23089
23090
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 8864564 times.
8865072 if(types[i]==cPIT)
23091 {
23092 508 index=0;
23093 508 warpsfx2 = combobuf[cids[i]].attribytes[0];
23094 508 }
23095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864564 times.
8864564 else if(types[i]==cPITB)
23096 {
23097 types[i]=cPIT;
23098 warpsfx2 = combobuf[cids[i]].attribytes[0];
23099 index=1;
23100 }
23101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864564 times.
8864564 else if(types[i]==cPITC)
23102 {
23103 types[i]=cPIT;
23104 warpsfx2 = combobuf[cids[i]].attribytes[0];
23105 index=2;
23106 }
23107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864564 times.
8864564 else if(types[i]==cPITD)
23108 {
23109 types[i]=cPIT;
23110 warpsfx2 = combobuf[cids[i]].attribytes[0];
23111 index=3;
23112 }
23113
1/2
✓ Branch 0 taken 8864564 times.
✗ Branch 1 not taken.
8864564 else if(types[i]==cPITR)
23114 {
23115 types[i]=cPIT;
23116 warpsfx2 = combobuf[cids[i]].attribytes[0];
23117 index=zc_oldrand()%4;
23118 }
23119
23120
2/2
✓ Branch 0 taken 10748 times.
✓ Branch 1 taken 8854324 times.
8865072 if(types[i]==cSTAIR)
23121 {
23122 10748 index=0;
23123 10748 warpsfx2 = combobuf[cids[i]].attribytes[0];
23124 10748 }
23125
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8854224 times.
8854324 else if(types[i]==cSTAIRB)
23126 {
23127 100 types[i]=cSTAIR;
23128 100 warpsfx2 = combobuf[cids[i]].attribytes[0];
23129 100 index=1;
23130 100 }
23131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8854224 times.
8854224 else if(types[i]==cSTAIRC)
23132 {
23133 types[i]=cSTAIR;
23134 warpsfx2 = combobuf[cids[i]].attribytes[0];
23135 index=2;
23136 }
23137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8854224 times.
8854224 else if(types[i]==cSTAIRD)
23138 {
23139 types[i]=cSTAIR;
23140 warpsfx2 = combobuf[cids[i]].attribytes[0];
23141 index=3;
23142 }
23143
1/2
✓ Branch 0 taken 8854224 times.
✗ Branch 1 not taken.
8854224 else if(types[i]==cSTAIRR)
23144 {
23145 types[i]=cSTAIR;
23146 index=zc_oldrand()%4;
23147 warpsfx2 = combobuf[cids[i]].attribytes[0];
23148 }
23149
23150
2/2
✓ Branch 0 taken 1279 times.
✓ Branch 1 taken 8863793 times.
8865072 if(types[i]==cCAVE2)
23151 {
23152 1279 index=0;
23153 1279 warpsfx2 = combobuf[cids[i]].attribytes[0];
23154 1279 }
23155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8863793 times.
8863793 else if(types[i]==cCAVE2B)
23156 {
23157 types[i]=cCAVE2;
23158 index=1;
23159 warpsfx2 = combobuf[cids[i]].attribytes[0];
23160 }
23161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8863793 times.
8863793 else if(types[i]==cCAVE2C)
23162 {
23163 types[i]=cCAVE2;
23164 warpsfx2 = combobuf[cids[i]].attribytes[0];
23165 index=2;
23166 }
23167
1/2
✓ Branch 0 taken 8863793 times.
✗ Branch 1 not taken.
8863793 else if(types[i]==cCAVE2D)
23168 {
23169 types[i]=cCAVE2;
23170 warpsfx2 = combobuf[cids[i]].attribytes[0];
23171 index=3;
23172 }
23173
23174
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 8864996 times.
8865072 if(types[i]==cSWIMWARP)
23175 {
23176 76 index=0;
23177 76 warpsfx2 = combobuf[cids[i]].attribytes[0];
23178 76 }
23179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864996 times.
8864996 else if(types[i]==cSWIMWARPB)
23180 {
23181 types[i]=cSWIMWARP;
23182 warpsfx2 = combobuf[cids[i]].attribytes[0];
23183 index=1;
23184 }
23185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864996 times.
8864996 else if(types[i]==cSWIMWARPC)
23186 {
23187 types[i]=cSWIMWARP;
23188 warpsfx2 = combobuf[cids[i]].attribytes[0];
23189 index=2;
23190 }
23191
1/2
✓ Branch 0 taken 8864996 times.
✗ Branch 1 not taken.
8864996 else if(types[i]==cSWIMWARPD)
23192 {
23193 types[i]=cSWIMWARP;
23194 warpsfx2 = combobuf[cids[i]].attribytes[0];
23195 index=3;
23196 }
23197
23198
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 8864564 times.
8865072 if(types[i]==cDIVEWARP)
23199 {
23200 508 index=0;
23201 508 warpsfx2 = combobuf[cids[i]].attribytes[0];
23202 508 }
23203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864564 times.
8864564 else if(types[i]==cDIVEWARPB)
23204 {
23205 types[i]=cDIVEWARP;
23206 warpsfx2 = combobuf[cids[i]].attribytes[0];
23207 index=1;
23208 }
23209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864564 times.
8864564 else if(types[i]==cDIVEWARPC)
23210 {
23211 types[i]=cDIVEWARP;
23212 warpsfx2 = combobuf[cids[i]].attribytes[0];
23213 index=2;
23214 }
23215
1/2
✓ Branch 0 taken 8864564 times.
✗ Branch 1 not taken.
8864564 else if(types[i]==cDIVEWARPD)
23216 {
23217 types[i]=cDIVEWARP;
23218 warpsfx2 = combobuf[cids[i]].attribytes[0];
23219 index=3;
23220 }
23221
23222
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 8864382 times.
8865072 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
23223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864382 times.
8864382 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
23224
2/2
✓ Branch 0 taken 8864366 times.
✓ Branch 1 taken 16 times.
8864382 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
23225 8865072 }
23226
23227 // Special case for step combos; otherwise, they act oddly in some cases
23228
8/8
✓ Branch 0 taken 2065949 times.
✓ Branch 1 taken 150566 times.
✓ Branch 2 taken 2047360 times.
✓ Branch 3 taken 18589 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 169072 times.
✓ Branch 6 taken 22411 times.
✓ Branch 7 taken 22328 times.
2216515 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
23229 {
23230
7/8
✓ Branch 0 taken 2010234 times.
✓ Branch 1 taken 14715 times.
✓ Branch 2 taken 2010234 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 628 times.
✓ Branch 5 taken 2009606 times.
✓ Branch 6 taken 130 times.
✓ Branch 7 taken 498 times.
2069771 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
23231 2010104 type = types[1];
23232 2024949 }
23233
23234 //Generic Step
23235
7/8
✓ Branch 0 taken 2199971 times.
✓ Branch 1 taken 16378 times.
✓ Branch 2 taken 2199971 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 630 times.
✓ Branch 5 taken 2199341 times.
✓ Branch 6 taken 132 times.
✓ Branch 7 taken 498 times.
2216349 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
23236 {
23237 int32_t poses[4];
23238 int32_t sensPoses[4];
23239 2199839 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
23240 2199839 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
23241
4/6
✓ Branch 0 taken 1538219 times.
✓ Branch 1 taken 661620 times.
✓ Branch 2 taken 1538219 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1538219 times.
2199839 if(diagonalMovement||NO_GRIDLOCK)
23242 661620 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
23243 1538219 else getPoses(poses, tx, ty, tx+15, ty+15);
23244 2199839 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
23245 2199839 bool hasStep[4] = {false};
23246
2/2
✓ Branch 0 taken 8799356 times.
✓ Branch 1 taken 2199839 times.
10999195 for(auto p = 0; p < 4; ++p)
23247 {
23248
2/2
✓ Branch 0 taken 8798491 times.
✓ Branch 1 taken 61590302 times.
70388793 for(auto lyr = 0; lyr < 7; ++lyr)
23249 {
23250
2/2
✓ Branch 0 taken 28663544 times.
✓ Branch 1 taken 32926758 times.
61590302 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
23251
4/4
✓ Branch 0 taken 28663544 times.
✓ Branch 1 taken 32926758 times.
✓ Branch 2 taken 865 times.
✓ Branch 3 taken 61589437 times.
61590302 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
23252 61590302 || types[p] == cSTEP)
23253 {
23254 865 hasStep[p] = true;
23255 865 break;
23256 }
23257 61589437 }
23258 8799356 }
23259 2199839 bool canNormalStep = true;
23260
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 2200245 times.
2200344 for(auto p = 0; p < 4; ++p)
23261 {
23262
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 2199992 times.
2200245 if(poses[p] < 0) continue;
23263
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 2199740 times.
2199992 if(!hasStep[p])
23264 {
23265 2199740 canNormalStep = false;
23266 2199740 break;
23267 }
23268 252 }
23269
2/2
✓ Branch 0 taken 8799356 times.
✓ Branch 1 taken 2199839 times.
10999195 for(auto p = 0; p < 4; ++p)
23270 {
23271
2/2
✓ Branch 0 taken 61595492 times.
✓ Branch 1 taken 8799356 times.
70394848 for(auto lyr = 0; lyr < 7; ++lyr)
23272 {
23273
2/2
✓ Branch 0 taken 28666820 times.
✓ Branch 1 taken 32928672 times.
61595492 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
23274
2/2
✓ Branch 0 taken 24658725 times.
✓ Branch 1 taken 36936767 times.
61595492 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
23275
6/6
✓ Branch 0 taken 2772 times.
✓ Branch 1 taken 61592720 times.
✓ Branch 2 taken 1162 times.
✓ Branch 3 taken 1610 times.
✓ Branch 4 taken 1148 times.
✓ Branch 5 taken 14 times.
61595492 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
23276 {
23277 14 do_trigger_combo(lyr,poses[p]);
23278
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 9 times.
14 if(poses[p] == sensPoses[p]) continue;
23279 9 }
23280
4/4
✓ Branch 0 taken 24658720 times.
✓ Branch 1 taken 36936767 times.
✓ Branch 2 taken 24658655 times.
✓ Branch 3 taken 65 times.
61595487 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
23281 {
23282 65 do_trigger_combo(lyr,sensPoses[p]);
23283 65 }
23284 61595487 }
23285 8799356 }
23286 2199839 word c = tmpscr->numFFC();
23287
2/2
✓ Branch 0 taken 66402397 times.
✓ Branch 1 taken 2199839 times.
68602236 for(word i=0; i<c; i++)
23288 {
23289 66402397 bool found = false;
23290
2/2
✓ Branch 0 taken 132804794 times.
✓ Branch 1 taken 66402397 times.
199207191 for(auto xch = 0; xch < 2; ++xch)
23291 {
23292
2/2
✓ Branch 0 taken 265609588 times.
✓ Branch 1 taken 132804794 times.
398414382 for(auto ych = 0; ych < 2; ++ych)
23293 {
23294
2/2
✓ Branch 0 taken 265523693 times.
✓ Branch 1 taken 85895 times.
265609588 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
23295 {
23296 85895 found = true;
23297 85895 }
23298 265609588 }
23299 132804794 }
23300
2/2
✓ Branch 0 taken 66368452 times.
✓ Branch 1 taken 33945 times.
66402397 if (found)
23301 {
23302 33945 ffcdata& ffc = tmpscr->ffcs[i];
23303 33945 newcombo const* cmb = &combobuf[ffc.getData()];
23304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33945 times.
33945 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
23305 {
23306 do_trigger_combo_ffc(i);
23307 }
23308 33945 }
23309 66402397 }
23310 2199839 }
23311
23312 //
23313 // Now, let's check for Save combos...
23314 //
23315 2216349 x1 = tx+4;
23316 2216349 x2 = tx+11;
23317 2216349 y1 = ty+4;
23318 2216349 y2 = ty+11;
23319
23320 2216349 types[0] = COMBOTYPE(x1,y1);
23321 2216349 cids[0] = MAPCOMBO(x1,y1);
23322
23323
2/2
✓ Branch 0 taken 2193255 times.
✓ Branch 1 taken 23094 times.
2216349 if(MAPFFCOMBO(x1,y1))
23324 {
23325 23094 types[0] = FFCOMBOTYPE(x1,y1);
23326 23094 cids[0] = MAPFFCOMBO(x1,y1);
23327 23094 }
23328
23329 2216349 types[1] = COMBOTYPE(x1,y2);
23330 2216349 cids[1] = MAPCOMBO(x1,y2);
23331
23332
2/2
✓ Branch 0 taken 2198381 times.
✓ Branch 1 taken 17968 times.
2216349 if(MAPFFCOMBO(x1,y2))
23333 {
23334 17968 types[1] = FFCOMBOTYPE(x1,y2);
23335 17968 cids[1] = MAPFFCOMBO(x1,y2);
23336 17968 }
23337
23338 2216349 types[2] = COMBOTYPE(x2,y1);
23339 2216349 cids[2] = MAPCOMBO(x2,y1);
23340
23341
2/2
✓ Branch 0 taken 2193036 times.
✓ Branch 1 taken 23313 times.
2216349 if(MAPFFCOMBO(x2,y1))
23342 {
23343 23313 types[2] = FFCOMBOTYPE(x2,y1);
23344 23313 cids[2] = MAPFFCOMBO(x2,y1);
23345 23313 }
23346
23347 2216349 types[3] = COMBOTYPE(x2,y2);
23348 2216349 cids[3] = MAPCOMBO(x2,y2);
23349
23350
2/2
✓ Branch 0 taken 2197864 times.
✓ Branch 1 taken 18485 times.
2216349 if(MAPFFCOMBO(x2,y2))
23351 {
23352 18485 types[3] = FFCOMBOTYPE(x2,y2);
23353 18485 cids[3] = MAPFFCOMBO(x2,y2);
23354 18485 }
23355
23356
23357
2/2
✓ Branch 0 taken 2216349 times.
✓ Branch 1 taken 8865396 times.
11081745 for(int32_t i=0; i<4; i++)
23358 {
23359
2/2
✓ Branch 0 taken 8865072 times.
✓ Branch 1 taken 324 times.
8865396 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23360 {
23361
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 324 times.
✗ Branch 3 not taken.
324 if(types[i] == cSAVE || types[i] == cSAVE2)
23362 {
23363 types[i] = cNONE;
23364 setsave = false;
23365 break;
23366 }
23367 324 }
23368
2/2
✓ Branch 0 taken 8864110 times.
✓ Branch 1 taken 1286 times.
8865396 if(types[i]==cSAVE) setsave=true;
23369
23370
1/2
✓ Branch 0 taken 8865396 times.
✗ Branch 1 not taken.
8865396 if(types[i]==cSAVE2) setsave=true;
23371 8865396 }
23372
23373
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 2215918 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
2216349 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23374 {
23375 229 last_savepoint_id = cids[0];
23376 229 type = types[0];
23377 229 }
23378 //
23379 // Now, let's check for Drowning combos...
23380 //
23381
3/4
✓ Branch 0 taken 1454895 times.
✓ Branch 1 taken 761454 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1454895 times.
2216349 if(get_bit(quest_rules,qr_DROWN) || CanSideSwim())
23382 {
23383 761454 y1 = ty+9;
23384 761454 y2 = ty+15;
23385
2/2
✓ Branch 0 taken 231939 times.
✓ Branch 1 taken 529515 times.
761454 if (get_bit(quest_rules, qr_SMARTER_WATER))
23386 {
23387
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 230041 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1597 times.
233539 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
23388
2/2
✓ Branch 0 taken 1742 times.
✓ Branch 1 taken 156 times.
1898 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
23389
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 142 times.
1742 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
23390 1600 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
23391 231939 }
23392 else
23393 {
23394 529515 types[0] = COMBOTYPE(x1,y1);
23395
23396
2/2
✓ Branch 0 taken 11301 times.
✓ Branch 1 taken 518214 times.
529515 if(MAPFFCOMBO(x1,y1))
23397 11301 types[0] = FFCOMBOTYPE(x1,y1);
23398
23399 529515 types[1] = COMBOTYPE(x1,y2);
23400
23401
2/2
✓ Branch 0 taken 10868 times.
✓ Branch 1 taken 518647 times.
529515 if(MAPFFCOMBO(x1,y2))
23402 10868 types[1] = FFCOMBOTYPE(x1,y2);
23403
23404 529515 types[2] = COMBOTYPE(x2,y1);
23405
23406
2/2
✓ Branch 0 taken 12015 times.
✓ Branch 1 taken 517500 times.
529515 if(MAPFFCOMBO(x2,y1))
23407 12015 types[2] = FFCOMBOTYPE(x2,y1);
23408
23409 529515 types[3] = COMBOTYPE(x2,y2);
23410
23411
2/2
✓ Branch 0 taken 11358 times.
✓ Branch 1 taken 518157 times.
529515 if(MAPFFCOMBO(x2,y2))
23412 11358 types[3] = FFCOMBOTYPE(x2,y2);
23413
23414 529515 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
23415
2/2
✓ Branch 0 taken 11562 times.
✓ Branch 1 taken 517953 times.
529515 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
23416 11562 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
23417
23418
5/6
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 527623 times.
✓ Branch 2 taken 1888 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1852 times.
✗ Branch 5 not taken.
531367 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
23419
3/4
✓ Branch 0 taken 1852 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 1852 times.
✗ Branch 3 not taken.
1888 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
23420 1852 water = typec;
23421 }
23422 761454 }
23423
23424
23425 // Pits have a bigger 'hitbox' than stairs...
23426 2216349 x1 = tx+7;
23427 2216349 x2 = tx+8;
23428 2216349 y1 = ty+7+(bigHitbox?0:4);
23429 2216349 y2 = ty+8+(bigHitbox?0:4);
23430
23431 2216349 types[0] = COMBOTYPE(x1,y1);
23432 2216349 cids[0] = MAPCOMBO(x1,y1);
23433
23434
2/2
✓ Branch 0 taken 2197827 times.
✓ Branch 1 taken 18522 times.
2216349 if(MAPFFCOMBO(x1,y1))
23435 {
23436 18522 types[0] = FFCOMBOTYPE(x1,y1);
23437 18522 cids[0] = MAPFFCOMBO(x1,y1);
23438 18522 }
23439
23440 2216349 types[1] = COMBOTYPE(x1,y2);
23441 2216349 cids[1] = MAPCOMBO(x1,y2);
23442
23443
2/2
✓ Branch 0 taken 2197678 times.
✓ Branch 1 taken 18671 times.
2216349 if(MAPFFCOMBO(x1,y2))
23444 {
23445 18671 types[1] = FFCOMBOTYPE(x1,y2);
23446 18671 cids[1] = MAPFFCOMBO(x1,y2);
23447 18671 }
23448 2216349 types[2] = COMBOTYPE(x2,y1);
23449 2216349 cids[2] = MAPCOMBO(x2,y1);
23450
23451
2/2
✓ Branch 0 taken 2198095 times.
✓ Branch 1 taken 18254 times.
2216349 if(MAPFFCOMBO(x2,y1))
23452 {
23453 18254 types[2] = FFCOMBOTYPE(x2,y1);
23454 18254 cids[2] = MAPFFCOMBO(x2,y1);
23455 18254 }
23456
23457 2216349 types[3] = COMBOTYPE(x2,y2);
23458 2216349 cids[3] = MAPCOMBO(x2,y2);
23459
23460
2/2
✓ Branch 0 taken 2197940 times.
✓ Branch 1 taken 18409 times.
2216349 if(MAPFFCOMBO(x2,y2))
23461 {
23462 18409 types[3] = FFCOMBOTYPE(x2,y2);
23463 18409 cids[3] = MAPFFCOMBO(x2,y2);
23464 18409 }
23465
23466
2/2
✓ Branch 0 taken 8865396 times.
✓ Branch 1 taken 2216349 times.
11081745 for(int32_t i=0; i<4; i++)
23467 {
23468
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 8865132 times.
8865396 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23469 {
23470 264 types[i] = cNONE;
23471 264 continue;
23472 }
23473
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 8864752 times.
8865132 if(types[i]==cPIT)
23474 {
23475 380 index=0;
23476 380 warpsfx2 = combobuf[cids[i]].attribytes[0];
23477 380 }
23478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864752 times.
8864752 else if(types[i]==cPITB)
23479 {
23480 types[i]=cPIT;
23481 index=1;
23482 warpsfx2 = combobuf[cids[i]].attribytes[0];
23483 }
23484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8864752 times.
8864752 else if(types[i]==cPITC)
23485 {
23486 types[i]=cPIT;
23487 index=2;
23488 warpsfx2 = combobuf[cids[i]].attribytes[0];
23489 }
23490
1/2
✓ Branch 0 taken 8864752 times.
✗ Branch 1 not taken.
8864752 else if(types[i]==cPITD)
23491 {
23492 types[i]=cPIT;
23493 index=3;
23494 warpsfx2 = combobuf[cids[i]].attribytes[0];
23495 }
23496 8865132 }
23497
23498
6/8
✓ Branch 0 taken 2216256 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 2216256 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2216237 times.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2216237 times.
2216349 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
23499
3/8
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 112 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
224 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
23500 112 type=cPIT;
23501
23502 //
23503 // Time to act on our results for type, flag, flag2 and flag3...
23504 //
23505
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 2216120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
2216349 if(type==cSAVE&&currscr<128)
23506 229 *ls=1;
23507
23508
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2216349 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2216349 if(type==cSAVE2&&currscr<128)
23509 *ls=2;
23510
23511
7/8
✓ Branch 0 taken 2208331 times.
✓ Branch 1 taken 8018 times.
✓ Branch 2 taken 2197259 times.
✓ Branch 3 taken 11072 times.
✓ Branch 4 taken 2196729 times.
✓ Branch 5 taken 530 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2196729 times.
2216349 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
23512 {
23513 19620 fairycircle(REFILL_LIFE);
23514
23515
2/2
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 3259 times.
19620 if(fairyclk!=0) return;
23516 3259 }
23517
23518
4/8
✓ Branch 0 taken 2199988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2199988 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2199988 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2199988 times.
2199988 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
23519 {
23520 fairycircle(REFILL_MAGIC);
23521
23522 if(fairyclk!=0) return;
23523 }
23524
23525
4/8
✓ Branch 0 taken 2199988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2199988 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2199988 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2199988 times.
2199988 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
23526 {
23527 fairycircle(REFILL_ALL);
23528
23529 if(fairyclk!=0) return;
23530 }
23531
23532 // Just in case Hero was moved off of the fairy flag
23533
1/2
✓ Branch 0 taken 2199988 times.
✗ Branch 1 not taken.
2199988 if(refilling==REFILL_FAIRYDONE)
23534 {
23535 fairycircle(REFILL_NONE);
23536
23537 if(fairyclk!=0) return;
23538 }
23539
23540
5/8
✓ Branch 0 taken 2199979 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 2199979 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2199979 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2199979 times.
2199988 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
23541 {
23542 9 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
23543 9 win_game();
23544 9 return;
23545 }
23546
23547
4/4
✓ Branch 0 taken 2196415 times.
✓ Branch 1 taken 3564 times.
✓ Branch 2 taken 2196415 times.
✓ Branch 3 taken 3564 times.
2199979 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
23548 3564 return;
23549
23550
4/4
✓ Branch 0 taken 2196090 times.
✓ Branch 1 taken 325 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2196081 times.
2196415 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
23551 {
23552
23553
3/4
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
334 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_bit(quest_rules,qr_TRIGGERSREPEAT))
23554 {
23555 334 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
23556 334 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
23557 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
23558
23559
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 325 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
334 if(type==cTRIGFLAG && canPermSecret())
23560 {
23561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
23562
23563 9 hidden_entrance(0,true,false);
23564 9 }
23565 else
23566 {
23567 325 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
23568 325 hidden_entrance(0,true,only16_31);
23569 }
23570 334 }
23571 334 }
23572
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 2195739 times.
2196081 else if(!didstrig)
23573 {
23574 2195739 stepsecret = -1;
23575 2195739 }
23576
23577 //Better? Dock collision
23578
23579 // Drown if:
23580 // * Water (obviously walkable),
23581 // * Quest Rule allows it,
23582 // * Not on stepladder,
23583 // * Not jumping,
23584 // * Not hovering,
23585 // * Not rafting,
23586 // * Not swallowed,
23587 // * Not a dried lake.
23588
23589 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
23590
23591
13/22
✓ Branch 0 taken 3393 times.
✓ Branch 1 taken 2193022 times.
✓ Branch 2 taken 3393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3393 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 3386 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3010 times.
✓ Branch 15 taken 376 times.
✓ Branch 16 taken 3010 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 3010 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
2196415 if(water > 0 && ((get_bit(quest_rules,qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim()) && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE)
23592 {
23593
4/8
✓ Branch 0 taken 3000 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 3000 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3000 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3010 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
23594 {
23595
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!(ladderx+laddery)) drownCombo = water;
23596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (combobuf[water].usrflags&cflag1) Drown(1);
23597 10 else Drown();
23598
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 if(byte drown_sfx = combobuf[water].attribytes[4])
23599 8 sfx(drown_sfx, pan(int32_t(x)));
23600 10 }
23601
2/2
✓ Branch 0 taken 2891 times.
✓ Branch 1 taken 109 times.
3000 else if (!isSwimming())
23602 {
23603 109 SetSwim();
23604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (!IsSideSwim()) attackclk = charging = spins = 0;
23605 109 landswim=0;
23606 109 return;
23607 }
23608 2901 }
23609
23610
23611
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 2196143 times.
2196306 if(type==cSTEP)
23612 {
23613 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
23614
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 66 times.
163 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
23615 {
23616 66 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
23617
23618 if
23619 (
23620
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 4 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
23621
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
23622 && /*HEAVY*/
23623
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23624 )
23625
23626 {
23627 62 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
23628 62 tmpscr->data[stepnext]++;
23629
23630 62 }
23631
23632 if
23633 (
23634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
23635 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
23636 && /*HEAVY*/
23637 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23638 )
23639 {
23640 int32_t stepc = tmpscr->data[stepnext];
23641 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
23642 for(int32_t k=0; k<176; k++)
23643 {
23644 if(tmpscr->data[k]==stepc)
23645 {
23646 tmpscr->data[k]++;
23647 }
23648 }
23649 }
23650
23651 if
23652 (
23653
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 63 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
23654
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
23655 && /*HEAVY*/
23656
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23657 )
23658 {
23659 3 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
23660
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 for(int32_t k=0; k<176; k++)
23661 {
23662 if(
23663
3/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 507 times.
1050 (combobuf[tmpscr->data[k]].type==cSTEP)||
23664
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
23665
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 6 times.
528 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
23666 522 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
23667 )
23668 {
23669 21 tmpscr->data[k]++;
23670 21 }
23671 528 }
23672 3 }
23673 66 }
23674 163 }
23675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2196143 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2196143 else if(type==cSTEPSFX && action == walking)
23676 {
23677 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
23678 }
23679 2196143 else stepnext = -1;
23680
23681 2196306 detail_int[0]=tx;
23682 2196306 detail_int[1]=ty;
23683
23684
23685
8/8
✓ Branch 0 taken 2196078 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 342 times.
✓ Branch 3 taken 2195964 times.
✓ Branch 4 taken 2195157 times.
✓ Branch 5 taken 807 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 8 times.
2196319 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
23686
5/6
✓ Branch 0 taken 2195045 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 2195034 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 2195034 times.
✗ Branch 5 not taken.
2195157 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
23687
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2195021 times.
2195034 !(type==cDIVEWARP && isDiving()))
23688 2195029 {
23689 RaftingStuff:
23690
2/2
✓ Branch 0 taken 2194470 times.
✓ Branch 1 taken 559 times.
2195029 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
23691 {
23692 559 bool doraft = true;
23693
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
23694 {
23695
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23696 {
23697 3 doraft = false;
23698 3 }
23699 3 }
23700 //if (mfRAFT)
23701 int32_t rafttypes[2];
23702 559 int32_t raftx1 = tx+6;
23703 559 int32_t raftx2 = tx+9;
23704 559 int32_t rafty = ty+11;
23705 int32_t raftflags[3];
23706 559 rafttypes[0]=rafttypes[1]=-1;
23707 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
23708 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
23709 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
23710
23711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23712 559 raftflags[0] = rafttypes[0];
23713
23714
23715 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
23716 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
23717
23718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23719 559 raftflags[1] = rafttypes[0];
23720
23721 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
23722 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
23723
23724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23725 559 raftflags[2] = rafttypes[0];
23726
23727
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
23728 {
23729
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
23730 {
23731 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
23732 {
23733 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
23734 {
23735 reset_swordcharge();
23736 action=rafting; FFCore.setHeroAction(rafting);
23737 raftclk=0;
23738 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23739 else sfx(tmpscr->secretsfx);
23740 }
23741 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23742 {
23743 for (int32_t i = 0; i < 4; ++i)
23744 {
23745 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
23746 {
23747 reset_swordcharge();
23748 action=rafting; FFCore.setHeroAction(rafting);
23749 raftclk=0;
23750 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23751 else sfx(tmpscr->secretsfx);
23752 dir = i;
23753 break;
23754 }
23755 }
23756 }
23757 }
23758 }
23759 1677 }
23760 559 }
23761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195029 times.
2195029 if (RaftPass) return;
23762
3/3
✓ Branch 0 taken 10772 times.
✓ Branch 1 taken 2183851 times.
✓ Branch 2 taken 406 times.
2195029 switch(flag)
23763 {
23764 case mfDIVE_ITEM:
23765
6/8
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 397 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
406 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23766 {
23767 12 additem(x, y, tmpscr->catchall,
23768 6 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23769 6 sfx(tmpscr->secretsfx);
23770 6 }
23771
23772 406 return;
23773
23774 case mfRAFT:
23775 case mfRAFT_BRANCH:
23776
23777 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
23778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10772 times.
10772 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
23779 {
23780 10772 bool doraft = true;
23781
5/6
✓ Branch 0 taken 10772 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 948 times.
✓ Branch 3 taken 9824 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 826 times.
10772 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
23782 {
23783
5/6
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392 times.
✓ Branch 3 taken 434 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 374 times.
826 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23784 {
23785 374 doraft = false;
23786 374 }
23787 826 }
23788
13/16
✓ Branch 0 taken 9636 times.
✓ Branch 1 taken 1136 times.
✓ Branch 2 taken 1924 times.
✓ Branch 3 taken 7712 times.
✓ Branch 4 taken 1914 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 1911 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 1911 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1911 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1911 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1262 times.
✓ Branch 15 taken 649 times.
10772 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
23789 {
23790
3/4
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 178 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 471 times.
649 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
23791 {
23792 178 reset_swordcharge();
23793 178 action=rafting; FFCore.setHeroAction(rafting);
23794 178 raftclk=0;
23795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23796 178 else sfx(tmpscr->secretsfx);
23797 178 }
23798
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 471 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
471 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23799 {
23800 for (int32_t i = 0; i < 4; ++i)
23801 {
23802 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
23803 {
23804 reset_swordcharge();
23805 action=rafting; FFCore.setHeroAction(rafting);
23806 raftclk=0;
23807 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23808 else sfx(tmpscr->secretsfx);
23809 dir = i;
23810 break;
23811 }
23812 }
23813 }
23814 649 }
23815 10772 }
23816
23817 10772 return;
23818
23819 default:
23820 2183851 break;
23821 //return;
23822 }
23823
23824
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2183851 times.
✗ Branch 2 not taken.
2183851 switch(flag2)
23825 {
23826 case mfDIVE_ITEM:
23827 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23828 {
23829 additem(x, y, tmpscr->catchall,
23830 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23831 sfx(tmpscr->secretsfx);
23832 }
23833
23834 return;
23835
23836 case mfRAFT:
23837 case mfRAFT_BRANCH:
23838
23839 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
23840 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
23841 {
23842 bool doraft = true;
23843 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
23844 {
23845 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23846 {
23847 doraft = false;
23848 }
23849 }
23850 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
23851 {
23852 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
23853 {
23854 reset_swordcharge();
23855 action=rafting; FFCore.setHeroAction(rafting);
23856 raftclk=0;
23857 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23858 else sfx(tmpscr->secretsfx);
23859 }
23860 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23861 {
23862 for (int32_t i = 0; i < 4; ++i)
23863 {
23864 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
23865 {
23866 reset_swordcharge();
23867 action=rafting; FFCore.setHeroAction(rafting);
23868 raftclk=0;
23869 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23870 else sfx(tmpscr->secretsfx);
23871 dir = i;
23872 break;
23873 }
23874 }
23875 }
23876 }
23877 }
23878
23879 return;
23880
23881 default:
23882 2183851 break;
23883 //return;
23884 }
23885
23886
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2183851 times.
✗ Branch 2 not taken.
2183851 switch(flag3)
23887 {
23888 case mfDIVE_ITEM:
23889 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23890 {
23891 additem(x, y, tmpscr->catchall,
23892 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23893 sfx(tmpscr->secretsfx);
23894 }
23895
23896 return;
23897
23898 case mfRAFT:
23899 case mfRAFT_BRANCH:
23900
23901 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
23902 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
23903 {
23904 bool doraft = true;
23905 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
23906 {
23907 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23908 {
23909 doraft = false;
23910 }
23911 }
23912 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
23913 {
23914 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
23915 {
23916 reset_swordcharge();
23917 action=rafting; FFCore.setHeroAction(rafting);
23918 raftclk=0;
23919 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23920 else sfx(tmpscr->secretsfx);
23921 }
23922 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
23923 {
23924 for (int32_t i = 0; i < 4; ++i)
23925 {
23926 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
23927 {
23928 reset_swordcharge();
23929 action=rafting; FFCore.setHeroAction(rafting);
23930 raftclk=0;
23931 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23932 else sfx(tmpscr->secretsfx);
23933 dir = i;
23934 break;
23935 }
23936 }
23937 }
23938 }
23939 }
23940
23941 return;
23942
23943 default:
23944 2183851 return;
23945 }
23946 }
23947
23948
23949 1277 int32_t t=(currscr<128)?0:1;
23950
23951
3/4
✓ Branch 0 taken 1049 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 1277 times.
✗ Branch 3 not taken.
1277 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
23952
23953 //don't do this for canceled warps -DD
23954 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
23955 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
23956 {
23957 draw_screen(tmpscr);
23958 advanceframe(true);
23959 }*/
23960
23961 1277 bool skippedaframe=false;
23962
23963
6/6
✓ Branch 0 taken 1049 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 935 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 807 times.
✓ Branch 5 taken 128 times.
1277 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
23964 {
23965 // Stop music only if:
23966 // * entering a Guy Cave
23967 // * warping to a DMap whose music is different.
23968
23969 1149 int32_t tdm = tmpscr[t].tilewarpdmap[index];
23970
23971
2/2
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 415 times.
1149 if(tmpscr[t].tilewarptype[index]<=wtPASS)
23972 {
23973
3/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 339 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 395 times.
734 if((DMaps[currdmap].flags&dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
23974 395 music_stop();
23975 734 }
23976 else
23977 {
23978
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 405 times.
415 if(zcmusic!=NULL)
23979 {
23980
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 if(strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
23981
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 (zcmusic->type==ZCMF_GME && zcmusic->track!=DMaps[tdm].tmusictrack))
23982 10 music_stop();
23983 10 }
23984
3/4
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 352 times.
405 else if(DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi-ZC_MIDI_COUNT+4) &&
23985 352 TheMaps[(DMaps[tdm].map*MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi-ZC_MIDI_COUNT+4))
23986 352 music_stop();
23987 }
23988
23989 1149 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
23990
5/6
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 415 times.
✓ Branch 2 taken 395 times.
✓ Branch 3 taken 339 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 395 times.
1149 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
23991 810 ? false : COOLSCROLL);
23992
23993 1149 FFCore.warpScriptCheck();
23994 1149 draw_screen(tmpscr);
23995 1149 advanceframe(true);
23996
23997 1149 skippedaframe=true;
23998
23999
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 1035 times.
1149 if(type==cCAVE2) walkup2(opening);
24000
2/2
✓ Branch 0 taken 807 times.
✓ Branch 1 taken 228 times.
1035 else if(type==cCAVE) walkdown(opening);
24001 1149 }
24002
24003
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 112 times.
1277 if(type==cPIT)
24004 {
24005 112 didpit=true;
24006 112 pitx=x;
24007 112 pity=y;
24008 112 warp_sound = warpsfx2;
24009 112 }
24010
24011
5/6
✓ Branch 0 taken 695 times.
✓ Branch 1 taken 582 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 56 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
1333 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
24012
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
695 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
24013 {
24014
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(!skippedaframe)
24015 {
24016 FFCore.warpScriptCheck();
24017 draw_screen(tmpscr);
24018 advanceframe(true);
24019 }
24020
24021 // "take any road you want"
24022
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 11 times.
56 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
24023 56 int32_t code = WARPCODE(currdmap,homescr,dw);
24024
24025
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(code>-1)
24026 {
24027 56 bool changedlevel = false;
24028 56 bool changeddmap = false;
24029
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15 times.
56 if(currdmap != code>>8)
24030 {
24031 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24032 15 changeddmap = true;
24033 15 }
24034
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(dlevel != DMaps[code>>8].level)
24035 {
24036 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24037 changedlevel = true;
24038 }
24039 56 currdmap = code>>8;
24040 56 dlevel = DMaps[currdmap].level;
24041
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15 times.
56 if(changeddmap)
24042 {
24043 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24044 15 }
24045
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(changedlevel)
24046 {
24047 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24048 }
24049
24050 56 currmap = DMaps[currdmap].map;
24051 56 homescr = (code&0xFF) + DMaps[currdmap].xoff;
24052 56 init_dmap();
24053
24054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(canPermSecret())
24055 56 setmapflag(mSECRET);
24056 56 }
24057
24058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(specialcave==STAIRCAVE) exitcave();
24059
24060 56 return;
24061 }
24062
24063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 if(type==cRESET)
24064 {
24065 if(!skippedaframe)
24066 {
24067 FFCore.warpScriptCheck();
24068 draw_screen(tmpscr);
24069 advanceframe(true);
24070 }
24071
24072 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
24073
24074 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
24075
24076 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
24077
24078 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
24079
24080 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
24081
24082 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
24083
24084 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
24085
24086 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
24087
24088 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
24089
24090 if(isdungeon())
24091 {
24092 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
24093
24094 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
24095
24096 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
24097
24098 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
24099 }
24100
24101 didpit=true;
24102 pitx=x;
24103 pity=y;
24104 sdir=dir;
24105 dowarp(4,0, warpsfx2);
24106 }
24107 else
24108 {
24109
3/4
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 1093 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
1221 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
24110 {
24111 128 FFCore.warpScriptCheck();
24112 128 draw_screen(tmpscr);
24113 128 advanceframe(true);
24114 128 }
24115
24116 1221 sdir = dir;
24117 1221 dowarp(0,index, warpsfx2);
24118 }
24119 6403147 }
24120
24121 67 int32_t selectWlevel(int32_t d)
24122 {
24123
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(TriforceCount()==0)
24124 return 0;
24125
24126 67 word l = game->get_wlevel();
24127
24128 67 do
24129 {
24130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
121 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
24131 break;
24132
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 52 times.
121 else if(d<0)
24133
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 11 times.
52 l = (l==0) ? 7 : l-1;
24134 else
24135
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 58 times.
69 l = (l==7) ? 0 : l+1;
24136
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 67 times.
121 }
24137 121 while(!(game->lvlitems[l+1] & liTRIFORCE));
24138
24139 67 game->set_wlevel(l);
24140 67 return l;
24141 67 }
24142
24143 // Would someone tell the Dodongos to shut their yaps?!
24144 11408 void kill_enemy_sfx()
24145 {
24146
2/2
✓ Branch 0 taken 11408 times.
✓ Branch 1 taken 21237 times.
32645 for(int32_t i=0; i<guys.Count(); i++)
24147 {
24148
2/2
✓ Branch 0 taken 7628 times.
✓ Branch 1 taken 13609 times.
21237 if(((enemy*)guys.spr(i))->bgsfx)
24149 13609 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
24150 21237 }
24151
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11342 times.
11408 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
24152
2/2
✓ Branch 0 taken 11395 times.
✓ Branch 1 taken 13 times.
11408 if(tmpscr->room==rGANON)
24153 13 stop_sfx(WAV_ROAR);
24154 11408 }
24155
24156 555 bool HeroClass::HasHeavyBoots()
24157 {
24158
2/2
✓ Branch 0 taken 555 times.
✓ Branch 1 taken 142080 times.
142635 for ( int32_t q = 0; q < MAXITEMS; ++q )
24159 {
24160
5/6
✓ Branch 0 taken 1665 times.
✓ Branch 1 taken 140415 times.
✓ Branch 2 taken 555 times.
✓ Branch 3 taken 1110 times.
✓ Branch 4 taken 555 times.
✗ Branch 5 not taken.
142080 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
24161 142080 }
24162 555 return false;
24163 555 }
24164
24165 const char *roomtype_string[rMAX] =
24166 {
24167 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
24168 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
24169 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
24170 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
24171 };
24172
24173 static bool refresh_dmap_scrollscript = false;
24174 2121 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
24175 {
24176 2121 refresh_dmap_scrollscript = false;
24177 2121 byte reposition_sword_postwarp = 0;
24178
1/2
✓ Branch 0 taken 2121 times.
✗ Branch 1 not taken.
2121 if(index<0)
24179 {
24180 return false;
24181 }
24182 2121 is_warping = true;
24183
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 2121 times.
2303 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
24184 {
24185 182 weapon *swd=NULL;
24186 182 swd = (weapon*)Lwpns.spr(q);
24187
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 8 times.
182 if(swd->id == (attack==wSword ? wSword : wWand))
24188 {
24189 8 Lwpns.del(q);
24190 8 }
24191 182 }
24192
24193 2121 attackclk = charging = spins = tapping = 0;
24194 2121 attack = none;
24195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2121 times.
2121 if ( warp_sound > 0 ) warpsfx = warp_sound;
24196 2121 warp_sound = 0;
24197 2121 word wdmap=0;
24198 2121 byte wscr=0,wtype=0,t=0;
24199 2121 bool overlay=false;
24200 2121 t=(currscr<128)?0:1;
24201 2121 int32_t wrindex = 0;
24202 2121 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
24203
24204 // Drawing commands probably shouldn't carry over...
24205
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2056 times.
2121 if ( !get_bit(quest_rules,qr_SCRIPTDRAWSINWARPS) )
24206 2056 script_drawing_commands.Clear();
24207
24208
4/6
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 1224 times.
✓ Branch 2 taken 766 times.
✓ Branch 3 taken 66 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2121 switch(type)
24209 {
24210 case 0: // tile warp
24211 1224 wtype = tmpscr[t].tilewarptype[index];
24212 1224 wdmap = tmpscr[t].tilewarpdmap[index];
24213 1224 wscr = tmpscr[t].tilewarpscr[index];
24214 1224 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
24215 1224 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
24216 1224 break;
24217
24218 case 1: // side warp
24219 766 wtype = tmpscr[t].sidewarptype[index];
24220 766 wdmap = tmpscr[t].sidewarpdmap[index];
24221 766 wscr = tmpscr[t].sidewarpscr[index];
24222 766 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
24223 766 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
24224 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
24225 //there is no doscript for screen scripts. They run like ffcs.
24226
24227 766 break;
24228
24229 case 2: // whistle warp
24230 {
24231 66 wtype = wtWHISTLE;
24232
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
24233 66 int32_t level=0;
24234
24235
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(blowcnt==0)
24236 level = selectWlevel(0);
24237 else
24238 {
24239
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 66 times.
133 for(int32_t i=0; i<abs(blowcnt); i++)
24240 67 level = selectWlevel(blowcnt);
24241 }
24242
24243
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
24244 {
24245 level %= QMisc.warp[wind].size;
24246 game->set_wlevel(level);
24247 }
24248
24249 66 wdmap = QMisc.warp[wind].dmap[level];
24250 66 wscr = QMisc.warp[wind].scr[level];
24251 }
24252 66 break;
24253
24254 case 3:
24255 wtype = wtIWARP;
24256 wdmap = cheat_goto_dmap;
24257 wscr = cheat_goto_screen;
24258 break;
24259
24260 case 4:
24261 wtype = wtIWARP;
24262 wdmap = currdmap;
24263 wscr = homescr-DMaps[currdmap].xoff;
24264 break;
24265 }
24266
24267 2121 bool intradmap = (wdmap == currdmap);
24268 2121 int32_t olddmap = currdmap;
24269 2121 rehydratelake(type!=wtSCROLL);
24270
24271
7/8
✓ Branch 0 taken 691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 450 times.
✓ Branch 3 taken 228 times.
✓ Branch 4 taken 423 times.
✓ Branch 5 taken 249 times.
✓ Branch 6 taken 66 times.
✓ Branch 7 taken 14 times.
2121 switch(wtype)
24272 {
24273 case wtCAVE:
24274 {
24275 // cave/item room
24276 450 ALLOFF();
24277 450 homescr=currscr;
24278 450 currscr=0x80;
24279
24280
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 111 times.
450 if(DMaps[currdmap].flags&dmfCAVES) // cave
24281 {
24282 339 music_stop();
24283 339 kill_sfx();
24284
24285
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 278 times.
339 if(tmpscr->room==rWARP)
24286 {
24287 61 currscr=0x81;
24288 61 specialcave = STAIRCAVE;
24289 61 }
24290 278 else specialcave = GUYCAVE;
24291
24292 //lighting(2,dir);
24293 339 lighting(false, true);
24294 339 loadlvlpal(10);
24295
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 38 times.
640 bool b2 = COOLSCROLL&&
24296
3/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
301 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
24297
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
24298
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
24299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
24300 339 blackscr(30,b2?false:true);
24301 339 loadscr(0,wdmap,currscr,up,false);
24302 339 loadscr(1,wdmap,homescr,up,false);
24303 //preloaded freeform combos
24304 339 ffscript_engine(true);
24305 339 putscr(scrollbuf,0,0,tmpscr);
24306 339 putscrdoors(scrollbuf,0,0,tmpscr);
24307 339 dir=up;
24308 339 x=112;
24309 339 y=160;
24310
1/2
✓ Branch 0 taken 339 times.
✗ Branch 1 not taken.
339 if(didpit)
24311 {
24312 didpit=false;
24313 x=pitx;
24314 y=pity;
24315 }
24316
24317 339 reset_hookshot();
24318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if(reposition_sword_postwarp)
24319 {
24320 weapon *swd=NULL;
24321 for(int32_t i=0; i<Lwpns.Count(); i++)
24322 {
24323 swd = (weapon*)Lwpns.spr(i);
24324
24325 if(swd->id == (attack==wSword ? wSword : wWand))
24326 {
24327 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24328 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24329 positionSword(swd,item_id);
24330 break;
24331 }
24332 }
24333 }
24334 339 stepforward(diagonalMovement?5:6, false);
24335 339 }
24336 else // item room
24337 {
24338 111 specialcave = ITEMCELLAR;
24339 111 map_bkgsfx(false);
24340 111 kill_enemy_sfx();
24341 111 draw_screen(tmpscr,false);
24342
24343 //unless the room is already dark, fade to black
24344
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 110 times.
111 if(!darkroom)
24345 {
24346 110 darkroom = true;
24347 110 fade(DMaps[currdmap].color,true,false);
24348 110 }
24349
24350 111 blackscr(30,true);
24351 111 loadscr(0,wdmap,currscr,down,false);
24352 111 loadscr(1,wdmap,homescr,-1,false);
24353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( dontdraw < 2 ) { dontdraw=1; }
24354 111 draw_screen(tmpscr);
24355 111 fade(11,true,true);
24356 111 darkroom = false;
24357 111 dir=down;
24358 111 x=48;
24359 111 y=0;
24360
24361 // is this didpit check necessary?
24362
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(didpit)
24363 {
24364 didpit=false;
24365 x=pitx;
24366 y=pity;
24367 }
24368
24369 111 reset_hookshot();
24370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(reposition_sword_postwarp)
24371 {
24372 weapon *swd=NULL;
24373 for(int32_t i=0; i<Lwpns.Count(); i++)
24374 {
24375 swd = (weapon*)Lwpns.spr(i);
24376
24377 if(swd->id == (attack==wSword ? wSword : wWand))
24378 {
24379 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24380 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24381 positionSword(swd,item_id);
24382 break;
24383 }
24384 }
24385 }
24386 111 lighting(false, true);
24387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( dontdraw < 2 ) { dontdraw=0; }
24388 111 stepforward(diagonalMovement?16:18, false);
24389 }
24390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if (get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC)) playLevelMusic();
24391 450 break;
24392 }
24393
24394 case wtPASS: // passageway
24395 {
24396 228 map_bkgsfx(false);
24397 228 kill_enemy_sfx();
24398 228 ALLOFF();
24399 //play sound
24400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
24401 228 homescr=currscr;
24402 228 currscr=0x81;
24403 228 specialcave = PASSAGEWAY;
24404 228 byte warpscr2 = wscr + DMaps[wdmap].xoff;
24405 228 draw_screen(tmpscr,false);
24406
24407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(!get_bit(quest_rules, qr_NEW_DARKROOM))
24408 {
24409
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 220 times.
228 if(!darkroom)
24410 220 fade(DMaps[currdmap].color,true,false);
24411
24412 228 darkroom=true;
24413 228 }
24414 228 blackscr(30,true);
24415 228 loadscr(0,wdmap,currscr,down,false);
24416 228 loadscr(1,wdmap,homescr,-1,false);
24417 //preloaded freeform combos
24418 228 ffscript_engine(true);
24419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if ( dontdraw < 2 ) { dontdraw=1; }
24420 228 draw_screen(tmpscr);
24421 228 lighting(false, true);
24422 228 dir=down;
24423 228 x=48;
24424
24425
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 117 times.
228 if((homescr&15) > (warpscr2&15))
24426 {
24427 117 x=192;
24428 117 }
24429
24430
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4 times.
228 if((homescr&15) == (warpscr2&15))
24431 {
24432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((currscr>>4) > (warpscr2>>4))
24433 {
24434 4 x=192;
24435 4 }
24436 4 }
24437
24438 // is this didpit check necessary?
24439
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(didpit)
24440 {
24441 didpit=false;
24442 x=pitx;
24443 y=pity;
24444 }
24445
24446 228 y=0;
24447 228 set_respawn_point();
24448 228 trySideviewLadder();
24449 228 reset_hookshot();
24450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(reposition_sword_postwarp)
24451 {
24452 weapon *swd=NULL;
24453 for(int32_t i=0; i<Lwpns.Count(); i++)
24454 {
24455 swd = (weapon*)Lwpns.spr(i);
24456
24457 if(swd->id == (attack==wSword ? wSword : wWand))
24458 {
24459 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24460 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24461 positionSword(swd,item_id);
24462 break;
24463 }
24464 }
24465 }
24466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if ( dontdraw < 2 ) { dontdraw=0; }
24467 228 stepforward(diagonalMovement?16:18, false);
24468 228 newscr_clk=frame;
24469 228 activated_timed_warp=false;
24470 228 stepoutindex=index;
24471 228 stepoutscr = warpscr2;
24472 228 stepoutdmap = wdmap;
24473 228 stepoutwr=wrindex;
24474 }
24475 228 break;
24476
24477 case wtEXIT: // entrance/exit
24478 {
24479 423 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
24480 423 ALLOFF();
24481 423 music_stop();
24482 423 kill_sfx();
24483 423 blackscr(30,false);
24484 423 bool changedlevel = false;
24485 423 bool changeddmap = false;
24486
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 422 times.
423 if(currdmap != wdmap)
24487 {
24488 422 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24489 422 changeddmap = true;
24490 422 }
24491
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 405 times.
423 if(dlevel != DMaps[wdmap].level)
24492 {
24493 405 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24494 405 changedlevel = true;
24495 405 }
24496 423 dlevel = DMaps[wdmap].level;
24497 423 currdmap = wdmap;
24498
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 422 times.
423 if(changeddmap)
24499 {
24500 422 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24501 422 }
24502
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 405 times.
423 if(changedlevel)
24503 {
24504 405 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24505 405 }
24506
24507 423 currmap=DMaps[currdmap].map;
24508 423 init_dmap();
24509 423 update_subscreens(wdmap);
24510 423 loadfullpal();
24511 423 ringcolor(false);
24512 423 loadlvlpal(DMaps[currdmap].color);
24513 //lastentrance_dmap = currdmap;
24514 423 homescr = currscr = wscr + DMaps[currdmap].xoff;
24515 423 loadscr(0,currdmap,currscr,-1,overlay);
24516
24517
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 420 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
423 if((tmpscr->flags&fDARK) && !get_bit(quest_rules,qr_NEW_DARKROOM))
24518 {
24519
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules,qr_FADE))
24520 {
24521 interpolatedfade();
24522 }
24523 else
24524 {
24525 3 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
24526 }
24527
24528 3 darkroom=naturaldark=true;
24529 3 }
24530 else
24531 {
24532 420 darkroom=naturaldark=false;
24533 }
24534
24535 int32_t wrx,wry;
24536
24537
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 409 times.
423 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24538 {
24539 14 wrx=tmpscr->warpreturnx[0];
24540 14 wry=tmpscr->warpreturny[0];
24541 14 }
24542 else
24543 {
24544 409 wrx=tmpscr->warparrivalx;
24545 409 wry=tmpscr->warparrivaly;
24546 }
24547
24548
6/6
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 355 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 371 times.
423 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
24549 {
24550
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 141 times.
371 if(dlevel)
24551 {
24552 230 lastentrance = currscr;
24553 230 }
24554 else
24555 {
24556 141 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
24557 }
24558
24559 371 lastentrance_dmap = wdmap;
24560 371 }
24561
24562
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 193 times.
423 if(dlevel)
24563 {
24564
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 223 times.
230 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24565 {
24566 7 x=tmpscr->warpreturnx[wrindex];
24567 7 y=tmpscr->warpreturny[wrindex];
24568 7 }
24569 else
24570 {
24571 223 x=tmpscr->warparrivalx;
24572 223 y=tmpscr->warparrivaly;
24573 }
24574 230 }
24575 else
24576 {
24577 193 x=tmpscr->warpreturnx[wrindex];
24578 193 y=tmpscr->warpreturny[wrindex];
24579 }
24580
24581
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 4 times.
423 if(didpit)
24582 {
24583 4 didpit=false;
24584 4 x=pitx;
24585 4 y=pity;
24586 4 }
24587
24588 423 dir=down;
24589
24590
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 407 times.
423 if(x==0) dir=right;
24591
24592
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 412 times.
423 if(x==240) dir=left;
24593
24594
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 409 times.
423 if(y==0) dir=down;
24595
24596
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 252 times.
423 if(y==160) dir=up;
24597
24598
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 193 times.
423 if(dlevel)
24599 {
24600 // reset enemy kill counts
24601
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 230 times.
29670 for(int32_t i=0; i<128; i++)
24602 {
24603 29440 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
24604 29440 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
24605 29440 }
24606 230 }
24607
24608 423 markBmap(dir^1);
24609 //preloaded freeform combos
24610 423 ffscript_engine(true);
24611
24612 423 reset_hookshot();
24613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(reposition_sword_postwarp)
24614 {
24615 weapon *swd=NULL;
24616 for(int32_t i=0; i<Lwpns.Count(); i++)
24617 {
24618 swd = (weapon*)Lwpns.spr(i);
24619
24620 if(swd->id == (attack==wSword ? wSword : wWand))
24621 {
24622 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24623 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24624 positionSword(swd,item_id);
24625 break;
24626 }
24627 }
24628 }
24629
24630
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 266 times.
423 if(isdungeon())
24631 {
24632 157 openscreen();
24633
3/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 123 times.
157 if(get_bit(extra_rules, er_SHORTDGNWALK)==0 && get_bit(quest_rules, qr_SHORTDGNWALK)==0)
24634 123 stepforward(diagonalMovement?11:12, false);
24635 else
24636 // Didn't walk as far pre-1.93, and some quests depend on that
24637 34 stepforward(8, false);
24638 157 }
24639 else
24640 {
24641
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 243 times.
266 if(!COOLSCROLL)
24642 23 openscreen();
24643
24644 266 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
24645 266 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
24646 266 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
24647
24648
5/10
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 178 times.
✓ Branch 4 taken 178 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 178 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
266 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
24649 {
24650 88 reset_pal_cycling();
24651 88 putscr(scrollbuf,0,0,tmpscr);
24652 88 putscrdoors(scrollbuf,0,0,tmpscr);
24653 88 walkup(COOLSCROLL);
24654 88 }
24655
5/10
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
✓ Branch 4 taken 175 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 175 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
178 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
24656 {
24657 3 reset_pal_cycling();
24658 3 putscr(scrollbuf,0,0,tmpscr);
24659 3 putscrdoors(scrollbuf,0,0,tmpscr);
24660 3 walkdown2(COOLSCROLL);
24661 3 }
24662
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 13 times.
175 else if(COOLSCROLL)
24663 {
24664 162 openscreen();
24665 162 }
24666 }
24667
24668 423 show_subscreen_life=true;
24669 423 show_subscreen_numbers=true;
24670 423 playLevelMusic();
24671 423 currcset=DMaps[currdmap].color;
24672 423 dointro();
24673 423 set_respawn_point();
24674 423 trySideviewLadder();
24675
24676
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 423 times.
2961 for(int32_t i=0; i<6; i++)
24677 2538 visited[i]=-1;
24678
24679 423 break;
24680 }
24681
24682 case wtSCROLL: // scrolling warp
24683 {
24684 249 int32_t c = DMaps[currdmap].color;
24685 249 scrolling_map = currmap;
24686 249 currmap = DMaps[wdmap].map;
24687 249 update_subscreens(wdmap);
24688
24689 249 dlevel = DMaps[wdmap].level;
24690 //check if Hero has the map for the new location before updating the subscreen. ? -Z
24691 //This works only in one direction, if Hero had a map, to not having one.
24692 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
24693 249 update_subscreens(wdmap);
24694
24695 /*if ( has_item(itype_map, dlevel) )
24696 {
24697 //Blank the map during an intra-dmap scrolling warp.
24698 dlevel = -1; //a hack for the minimap. This works!! -Z
24699 }*/
24700
24701 // fix the scrolling direction, if it was a tile or instant warp
24702
2/4
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
249 if(type==0 || type>=3)
24703 {
24704 sdir = dir;
24705 }
24706
24707 249 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
24708 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
24709
24710 249 reset_hookshot();
24711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
249 if(reposition_sword_postwarp)
24712 {
24713 weapon *swd=NULL;
24714 for(int32_t i=0; i<Lwpns.Count(); i++)
24715 {
24716 swd = (weapon*)Lwpns.spr(i);
24717
24718 if(swd->id == (attack==wSword ? wSword : wWand))
24719 {
24720 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24721 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24722 positionSword(swd,item_id);
24723 break;
24724 }
24725 }
24726 }
24727
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 203 times.
249 if(!intradmap)
24728 {
24729 203 homescr = currscr = wscr + DMaps[wdmap].xoff;
24730 203 init_dmap();
24731
24732 int32_t wrx,wry;
24733
24734
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 99 times.
203 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24735 {
24736 104 wrx=tmpscr->warpreturnx[0];
24737 104 wry=tmpscr->warpreturny[0];
24738 104 }
24739 else
24740 {
24741 99 wrx=tmpscr->warparrivalx;
24742 99 wry=tmpscr->warparrivaly;
24743 }
24744
24745
7/8
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 129 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 68 times.
203 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!get_bit(quest_rules,qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
24746 {
24747
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 48 times.
68 if(dlevel)
24748 {
24749 20 lastentrance = currscr;
24750 20 }
24751 else
24752 {
24753 48 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
24754 }
24755
24756 68 lastentrance_dmap = wdmap;
24757 68 }
24758 203 }
24759
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 114 times.
249 if(DMaps[currdmap].color != c)
24760 {
24761 114 lighting(false, true);
24762 114 }
24763
24764 249 playLevelMusic();
24765 249 currcset=DMaps[currdmap].color;
24766 249 dointro();
24767 }
24768 249 break;
24769
24770 case wtWHISTLE: // whistle warp
24771 {
24772 66 scrolling_map = currmap;
24773 66 currmap = DMaps[wdmap].map;
24774 66 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
24775 66 reset_hookshot();
24776 66 currdmap=wdmap;
24777 66 dlevel=DMaps[currdmap].level;
24778 66 lighting(false, true);
24779 66 init_dmap();
24780
24781 66 playLevelMusic();
24782 66 currcset=DMaps[currdmap].color;
24783 66 dointro();
24784 66 action=inwind; FFCore.setHeroAction(inwind);
24785 int32_t wry;
24786
24787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24788 wry=tmpscr->warpreturny[0];
24789 66 else wry=tmpscr->warparrivaly;
24790
24791 int32_t wrx;
24792
24793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
24794 wrx=tmpscr->warpreturnx[0];
24795 66 else wrx=tmpscr->warparrivalx;
24796
24797
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 66 times.
✓ Branch 10 taken 66 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 66 times.
✗ Branch 13 not taken.
132 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
24798
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
66 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
24799 66 whirlwind=255;
24800 66 whistleitem=-1;
24801 }
24802 66 break;
24803
24804 case wtIWARP:
24805 case wtIWARPBLK:
24806 case wtIWARPOPEN:
24807 case wtIWARPZAP:
24808 case wtIWARPWAVE: // insta-warps
24809 {
24810 691 bool old_192 = false;
24811
1/2
✓ Branch 0 taken 691 times.
✗ Branch 1 not taken.
691 if (get_bit(quest_rules,qr_192b163_WARP))
24812 {
24813 if ( wtype == wtIWARPWAVE )
24814 {
24815 wtype = wtIWARPWAVE;
24816 old_192 = true;
24817 }
24818 if ( old_192 )
24819 {
24820 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
24821 didpit=false;
24822 update_subscreens();
24823 warp_sound = 0;
24824 is_warping = false;
24825 return false;
24826 }
24827 }
24828 //for determining whether to exit cave
24829 691 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
24830 691 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
24831 691 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
24832
24833
8/8
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 596 times.
✓ Branch 4 taken 617 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 604 times.
1337 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
24834
8/8
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 592 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 604 times.
✓ Branch 6 taken 592 times.
✓ Branch 7 taken 12 times.
617 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
24835
24836
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 626 times.
775 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
24837 {
24838 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
24839 626 bool wasswimming = (action == swimming);
24840 626 int32_t olddiveclk = diveclk;
24841 626 ALLOFF();
24842
24843
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 18 times.
626 if(wasswimming)
24844 {
24845 18 Hero.SetSwim();
24846 18 diveclk = olddiveclk;
24847 18 }
24848
24849 626 kill_sfx();
24850 626 }
24851 //play sound
24852
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 42 times.
627 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
24853
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 556 times.
625 if(wtype==wtIWARPZAP)
24854 {
24855 69 zapout();
24856 69 }
24857
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 518 times.
556 else if(wtype==wtIWARPWAVE)
24858 {
24859 //only draw Hero if he's not in a cave -DD
24860 38 wavyout(!cavewarp);
24861 38 }
24862
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 176 times.
518 else if(wtype!=wtIWARP)
24863 {
24864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
176 bool b2 = COOLSCROLL&&cavewarp;
24865 176 blackscr(30,b2?false:true);
24866 176 }
24867
24868 625 int32_t c = DMaps[currdmap].color;
24869 625 bool changedlevel = false;
24870 625 bool changeddmap = false;
24871
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 369 times.
625 if(currdmap != wdmap)
24872 {
24873 369 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24874 369 changeddmap = true;
24875 369 }
24876
2/2
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 166 times.
625 if(dlevel != DMaps[wdmap].level)
24877 {
24878 166 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24879 166 changedlevel = true;
24880 166 }
24881 625 dlevel = DMaps[wdmap].level;
24882 625 currdmap = wdmap;
24883
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 369 times.
625 if(changeddmap)
24884 {
24885 369 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24886 369 }
24887
2/2
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 166 times.
625 if(changedlevel)
24888 {
24889 166 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24890 166 }
24891
24892 625 currmap = DMaps[currdmap].map;
24893 625 init_dmap();
24894 625 update_subscreens(wdmap);
24895
24896 625 ringcolor(false);
24897
24898
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 270 times.
625 if(DMaps[currdmap].color != c)
24899 270 loadlvlpal(DMaps[currdmap].color);
24900
24901 625 homescr = currscr = wscr + DMaps[currdmap].xoff;
24902
24903 625 lightingInstant(); // Also sets naturaldark
24904
24905 625 loadscr(0,currdmap,currscr,-1,overlay);
24906
24907 625 x = tmpscr->warpreturnx[wrindex];
24908 625 y = tmpscr->warpreturny[wrindex];
24909
24910
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 237 times.
625 if(didpit)
24911 {
24912 237 didpit=false;
24913 237 x=pitx;
24914 237 y=pity;
24915 237 }
24916
24917 625 type1 = combobuf[MAPCOMBO(x,y-16)].type;
24918 625 type2 = combobuf[MAPCOMBO(x,y)].type;
24919 625 type3 = combobuf[MAPCOMBO(x,y+16)].type;
24920
24921
2/2
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 74 times.
625 if(x==0) dir=right;
24922
24923
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 2 times.
625 if(x==240) dir=left;
24924
24925
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 24 times.
625 if(y==0) dir=down;
24926
24927
2/2
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 29 times.
625 if(y==160) dir=up;
24928
24929 625 markBmap(dir^1);
24930
24931 625 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
24932
24933
10/16
✓ Branch 0 taken 611 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 14 times.
✓ Branch 12 taken 14 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
✓ Branch 15 taken 611 times.
639 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
24934 {
24935 14 hopclk=0xFF;
24936 14 SetSwim();
24937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (!IsSideSwim()) attackclk = charging = spins = 0;
24938 14 }
24939 else
24940 {
24941 611 action = none; FFCore.setHeroAction(none);
24942 }
24943 //preloaded freeform combos
24944 625 ffscript_engine(true);
24945
24946 625 putscr(scrollbuf,0,0,tmpscr);
24947 625 putscrdoors(scrollbuf,0,0,tmpscr);
24948
24949
10/10
✓ Branch 0 taken 621 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 597 times.
✓ Branch 4 taken 621 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 23 times.
✓ Branch 7 taken 598 times.
✓ Branch 8 taken 42 times.
✓ Branch 9 taken 65 times.
625 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
24950 {
24951 94 reset_pal_cycling();
24952 94 putscr(scrollbuf,0,0,tmpscr);
24953 94 putscrdoors(scrollbuf,0,0,tmpscr);
24954 94 walkup(COOLSCROLL);
24955 94 }
24956
9/10
✓ Branch 0 taken 621 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 621 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 600 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 21 times.
663 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
24957 {
24958 84 reset_pal_cycling();
24959 84 putscr(scrollbuf,0,0,tmpscr);
24960 84 putscrdoors(scrollbuf,0,0,tmpscr);
24961 84 walkdown2(COOLSCROLL);
24962 84 }
24963
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 551 times.
621 else if(wtype==wtIWARPZAP)
24964 {
24965 70 zapin();
24966 70 }
24967
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 513 times.
551 else if(wtype==wtIWARPWAVE)
24968 {
24969 38 wavyin();
24970 38 }
24971
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 83 times.
513 else if(wtype==wtIWARPOPEN)
24972 {
24973 83 openscreen();
24974 83 }
24975
1/2
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
715 if(reposition_sword_postwarp)
24976 {
24977 weapon *swd=NULL;
24978 for(int32_t i=0; i<Lwpns.Count(); i++)
24979 {
24980 swd = (weapon*)Lwpns.spr(i);
24981
24982 if(swd->id == (attack==wSword ? wSword : wWand))
24983 {
24984 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24985 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24986 positionSword(swd,item_id);
24987 break;
24988 }
24989 }
24990 }
24991 715 show_subscreen_life=true;
24992 715 show_subscreen_numbers=true;
24993 715 playLevelMusic();
24994 715 currcset=DMaps[currdmap].color;
24995 715 dointro();
24996 715 set_respawn_point();
24997 715 trySideviewLadder();
24998 }
24999 715 break;
25000
25001
25002 case wtNOWARP:
25003 {
25004 14 bool old_192 = false;
25005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (get_bit(quest_rules,qr_192b163_WARP))
25006 {
25007 wtype = wtIWARPWAVE;
25008 old_192 = true;
25009 }
25010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if ( old_192 )
25011 {
25012 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
25013 //for determining whether to exit cave
25014 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
25015 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25016 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
25017
25018 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
25019 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
25020
25021 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
25022 {
25023 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
25024 bool wasswimming = (action == swimming);
25025 int32_t olddiveclk = diveclk;
25026 ALLOFF();
25027
25028 if(wasswimming)
25029 {
25030 Hero.SetSwim();
25031 diveclk = olddiveclk;
25032 }
25033
25034 kill_sfx();
25035 }
25036 //play sound
25037 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
25038 if(wtype==wtIWARPZAP)
25039 {
25040 zapout();
25041 }
25042 else if(wtype==wtIWARPWAVE)
25043 {
25044 //only draw Hero if he's not in a cave -DD
25045 wavyout(!cavewarp);
25046 }
25047 else if(wtype!=wtIWARP)
25048 {
25049 bool b2 = COOLSCROLL&&cavewarp;
25050 blackscr(30,b2?false:true);
25051 }
25052
25053 int32_t c = DMaps[currdmap].color;
25054 bool changedlevel = false;
25055 bool changeddmap = false;
25056 if(currdmap != wdmap)
25057 {
25058 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25059 changeddmap = true;
25060 }
25061 if(dlevel != DMaps[wdmap].level)
25062 {
25063 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25064 changedlevel = true;
25065 }
25066 dlevel = DMaps[wdmap].level;
25067 currdmap = wdmap;
25068 if(changeddmap)
25069 {
25070 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25071 }
25072 if(changedlevel)
25073 {
25074 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25075 }
25076 currmap = DMaps[currdmap].map;
25077 init_dmap();
25078 update_subscreens(wdmap);
25079
25080 ringcolor(false);
25081
25082 if(DMaps[currdmap].color != c)
25083 loadlvlpal(DMaps[currdmap].color);
25084
25085 homescr = currscr = wscr + DMaps[currdmap].xoff;
25086
25087 lightingInstant(); // Also sets naturaldark
25088
25089 loadscr(0,currdmap,currscr,-1,overlay);
25090
25091 x = tmpscr->warpreturnx[wrindex];
25092 y = tmpscr->warpreturny[wrindex];
25093
25094 if(didpit)
25095 {
25096 didpit=false;
25097 x=pitx;
25098 y=pity;
25099 }
25100
25101 type1 = combobuf[MAPCOMBO(x,y-16)].type;
25102 type2 = combobuf[MAPCOMBO(x,y)].type;
25103 type3 = combobuf[MAPCOMBO(x,y+16)].type;
25104
25105 if(x==0) dir=right;
25106
25107 if(x==240) dir=left;
25108
25109 if(y==0) dir=down;
25110
25111 if(y==160) dir=up;
25112
25113 markBmap(dir^1);
25114
25115 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
25116 {
25117 hopclk=0xFF;
25118 SetSwim();
25119 if (!IsSideSwim()) attackclk = charging = spins = 0;
25120 }
25121 else
25122 {
25123 action = none;
25124 FFCore.setHeroAction(none);
25125 }
25126 //preloaded freeform combos
25127 ffscript_engine(true);
25128
25129 putscr(scrollbuf,0,0,tmpscr);
25130 putscrdoors(scrollbuf,0,0,tmpscr);
25131
25132 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25133 {
25134 reset_pal_cycling();
25135 putscr(scrollbuf,0,0,tmpscr);
25136 putscrdoors(scrollbuf,0,0,tmpscr);
25137 walkup(COOLSCROLL);
25138 }
25139 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25140 {
25141 reset_pal_cycling();
25142 putscr(scrollbuf,0,0,tmpscr);
25143 putscrdoors(scrollbuf,0,0,tmpscr);
25144 walkdown2(COOLSCROLL);
25145 }
25146 else if(wtype==wtIWARPZAP)
25147 {
25148 zapin();
25149 }
25150 else if(wtype==wtIWARPWAVE)
25151 {
25152 wavyin();
25153 }
25154 else if(wtype==wtIWARPOPEN)
25155 {
25156 openscreen();
25157 }
25158 if(reposition_sword_postwarp)
25159 {
25160 weapon *swd=NULL;
25161 for(int32_t i=0; i<Lwpns.Count(); i++)
25162 {
25163 swd = (weapon*)Lwpns.spr(i);
25164
25165 if(swd->id == (attack==wSword ? wSword : wWand))
25166 {
25167 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25168 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25169 positionSword(swd,item_id);
25170 break;
25171 }
25172 }
25173 }
25174 show_subscreen_life=true;
25175 show_subscreen_numbers=true;
25176 playLevelMusic();
25177 currcset=DMaps[currdmap].color;
25178 dointro();
25179 set_respawn_point();
25180 trySideviewLadder();
25181 break;
25182 }
25183 else
25184 {
25185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(reposition_sword_postwarp)
25186 {
25187 weapon *swd=NULL;
25188 for(int32_t i=0; i<Lwpns.Count(); i++)
25189 {
25190 swd = (weapon*)Lwpns.spr(i);
25191
25192 if(swd->id == (attack==wSword ? wSword : wWand))
25193 {
25194 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25195 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25196 positionSword(swd,item_id);
25197 break;
25198 }
25199 }
25200 }
25201 14 didpit=false;
25202 14 update_subscreens();
25203 14 warp_sound = 0;
25204 14 is_warping = false;
25205 14 return false;
25206 }
25207 }
25208 default:
25209 didpit=false;
25210 update_subscreens();
25211 warp_sound = 0;
25212 is_warping = false;
25213 if(reposition_sword_postwarp)
25214 {
25215 weapon *swd=NULL;
25216 for(int32_t i=0; i<Lwpns.Count(); i++)
25217 {
25218 swd = (weapon*)Lwpns.spr(i);
25219
25220 if(swd->id == (attack==wSword ? wSword : wWand))
25221 {
25222 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25223 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25224 positionSword(swd,item_id);
25225 break;
25226 }
25227 }
25228 }
25229 return false;
25230 }
25231
25232
25233
25234 // Stop Hero from drowning!
25235
5/6
✓ Branch 0 taken 2041 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 2041 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 1951 times.
2131 if(action==drowning || action==lavadrowning || action==sidedrowning)
25236 {
25237 180 drownclk=0;
25238 180 drownclk=0;
25239 180 action=none; FFCore.setHeroAction(none);
25240 180 }
25241
25242 1951 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
25243 // But keep him swimming if he ought to be!
25244 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
25245
9/12
✓ Branch 0 taken 2035 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 2007 times.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 28 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 2110 times.
✓ Branch 11 taken 17 times.
1979 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_bit(quest_rules,qr_DROWN))
25246 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
25247
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
28 && (action!=inwind))
25248 {
25249 17 hopclk=0xFF;
25250 17 SetSwim();
25251 17 }
25252
25253 2127 newscr_clk=frame;
25254 2127 activated_timed_warp=false;
25255 2127 eat_buttons();
25256
25257
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 1699 times.
2127 if(wtype!=wtIWARP)
25258 1699 attackclk=0;
25259
25260 2127 didstuff=0;
25261 2127 usecounts.clear();
25262 2127 map_bkgsfx(true);
25263 2127 loadside=dir^1;
25264 2127 whistleclk=-1;
25265
25266
3/4
✓ Branch 0 taken 2041 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 2131 times.
✗ Branch 3 not taken.
2127 if((z>0 || fakez>0) && isSideViewHero())
25267 {
25268 y-=z;
25269 y-=fakez;
25270 fakez=0;
25271 z=0;
25272 }
25273
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 1925 times.
2131 else if(!isSideViewHero())
25274 {
25275 1925 fall=0;
25276 1925 fakefall=0;
25277 1925 }
25278
25279 // If warping between top-down and sideview screens,
25280 // fix enemies that are carried over by Full Screen Warp
25281 2131 const bool tmpscr_is_sideview = isSideViewHero();
25282
25283
4/4
✓ Branch 0 taken 1928 times.
✓ Branch 1 taken 203 times.
✓ Branch 2 taken 1898 times.
✓ Branch 3 taken 30 times.
2131 if(!wasSideview && tmpscr_is_sideview)
25284 {
25285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 for(int32_t i=0; i<guys.Count(); i++)
25286 {
25287 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
25288 {
25289 guys.spr(i)->y -= guys.spr(i)->z;
25290 guys.spr(i)->y -= guys.spr(i)->fakez;
25291 guys.spr(i)->z = 0;
25292 guys.spr(i)->fakez = 0;
25293 }
25294
25295 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
25296 guys.spr(i)->yofs += 2;
25297 }
25298 30 }
25299
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 1988 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 27 times.
2101 else if(wasSideview && !tmpscr_is_sideview)
25300 {
25301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t i=0; i<guys.Count(); i++)
25302 {
25303 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
25304 guys.spr(i)->yofs -= 2;
25305 }
25306 27 }
25307
25308
6/6
✓ Branch 0 taken 1347 times.
✓ Branch 1 taken 784 times.
✓ Branch 2 taken 275 times.
✓ Branch 3 taken 1072 times.
✓ Branch 4 taken 204 times.
✓ Branch 5 taken 71 times.
2131 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_bit(quest_rules, qr_DMAP_0_CONTINUE_BUG)))
25309 {
25310
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 726 times.
988 if(dlevel)
25311 {
25312 int32_t wrx,wry;
25313
25314
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 213 times.
240 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
25315 {
25316 27 wrx=tmpscr->warpreturnx[0];
25317 27 wry=tmpscr->warpreturny[0];
25318 27 }
25319 else
25320 {
25321 213 wrx=tmpscr->warparrivalx;
25322 213 wry=tmpscr->warparrivaly;
25323 }
25324
25325
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
240 if((wtype == wtEXIT)
25326
7/10
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 173 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
240 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))))
25327 {
25328
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
63 if(!(wtype==wtSCROLL)||!(get_bit(quest_rules,qr_NOSCROLLCONTINUE)))
25329 {
25330 63 game->set_continue_scrn(homescr);
25331 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
25332 63 }
25333 else if(currdmap != game->get_continue_dmap())
25334 {
25335 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25336 }
25337 63 }
25338 else
25339 {
25340
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 22 times.
177 if(currdmap != game->get_continue_dmap())
25341 {
25342 22 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25343 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
25344 22 }
25345 }
25346 240 }
25347 else
25348 {
25349 726 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25350 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
25351 }
25352
25353 966 game->set_continue_dmap(currdmap);
25354 966 lastentrance_dmap = currdmap;
25355 966 lastentrance = game->get_continue_scrn();
25356 //Z_message("continue_map = %d\n",game->get_continue_dmap());
25357 966 }
25358
25359
1/2
✓ Branch 0 taken 2109 times.
✗ Branch 1 not taken.
2109 if(tmpscr->flags4&fAUTOSAVE)
25360 {
25361 save_game(true,0);
25362 }
25363
25364
2/2
✓ Branch 0 taken 2097 times.
✓ Branch 1 taken 12 times.
2109 if(tmpscr->flags6&fCONTINUEHERE)
25365 {
25366 12 lastentrance_dmap = currdmap;
25367 12 lastentrance = homescr;
25368 12 }
25369
25370 2109 update_subscreens();
25371 2109 verifyBothWeapons();
25372
25373
2/2
✓ Branch 0 taken 1659 times.
✓ Branch 1 taken 450 times.
2109 if(wtype==wtCAVE)
25374 {
25375
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 111 times.
450 if(DMaps[currdmap].flags&dmfGUYCAVES)
25376 678 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
25377 339 (char *)moduledata.roomtype_names[tmpscr[1].room]);
25378 else
25379 111 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
25380 450 }
25381 3318 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
25382
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 1363 times.
3022 wtype==wtPASS ? "Passageway" :
25383
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 940 times.
2303 wtype==wtEXIT ? "Entrance/Exit" :
25384
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 691 times.
940 wtype==wtSCROLL ? "Scrolling Warp" :
25385 691 wtype==wtWHISTLE ? "Whistle Warp" :
25386 "Insta-Warp");
25387
25388 2109 eventlog_mapflags();
25389
1/2
✓ Branch 0 taken 2109 times.
✗ Branch 1 not taken.
2109 if(reposition_sword_postwarp)
25390 {
25391 weapon *swd=NULL;
25392 for(int32_t i=0; i<Lwpns.Count(); i++)
25393 {
25394 swd = (weapon*)Lwpns.spr(i);
25395
25396 if(swd->id == (attack==wSword ? wSword : wWand))
25397 {
25398 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25399 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25400 positionSword(swd,item_id);
25401 break;
25402 }
25403 }
25404 }
25405 2109 FFCore.init_combo_doscript();
25406
4/4
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 1214 times.
✓ Branch 2 taken 827 times.
✓ Branch 3 taken 68 times.
2109 if (!intradmap || get_bit(quest_rules, qr_WARPS_RESTART_DMAPSCRIPT))
25407 {
25408 2041 FFScript::deallocateAllArrays(SCRIPT_DMAP, olddmap);
25409 2041 FFCore.initZScriptDMapScripts();
25410 2041 FFCore.initZScriptActiveSubscreenScript();
25411
1/2
✓ Branch 0 taken 2041 times.
✗ Branch 1 not taken.
2041 if(refresh_dmap_scrollscript)
25412 {
25413 run_scrolling_script_int(false); //Pre-waitdraw
25414 refresh_dmap_scrollscript = false;
25415 }
25416 2041 }
25417 2109 is_warping = false;
25418
1/2
✓ Branch 0 taken 2109 times.
✗ Branch 1 not taken.
2109 if(!get_bit(quest_rules,qr_SCROLLWARP_NO_RESET_FRAME))
25419 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
25420 2109 return true;
25421 2123 }
25422
25423 289 void HeroClass::exitcave()
25424 {
25425 289 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25426 289 currscr=homescr;
25427 289 loadscr(0,currdmap,currscr,255,false); // bogus direction
25428 289 x = tmpscr->warpreturnx[0];
25429 289 y = tmpscr->warpreturny[0];
25430
25431
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 if(didpit)
25432 {
25433 didpit=false;
25434 x=pitx;
25435 y=pity;
25436 }
25437
25438
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 15 times.
289 if(x+y == 0)
25439 15 x = y = 80;
25440
25441 289 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
25442 289 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25443 289 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
25444
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 268 times.
577 bool b = COOLSCROLL &&
25445
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 191 times.
268 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
25446
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 191 times.
191 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
25447
4/4
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 173 times.
191 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
25448
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 173 times.
✓ Branch 3 taken 5 times.
173 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
25449 309 ALLOFF();
25450 309 blackscr(30,b?false:true);
25451 309 ringcolor(false);
25452 309 loadlvlpal(DMaps[currdmap].color);
25453 309 lighting(false, true);
25454 309 music_stop();
25455 309 kill_sfx();
25456 309 putscr(scrollbuf,0,0,tmpscr);
25457 309 putscrdoors(scrollbuf,0,0,tmpscr);
25458
25459
9/10
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 211 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 206 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
309 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25460 {
25461 104 walkup(COOLSCROLL);
25462 104 }
25463
9/10
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 188 times.
✓ Branch 4 taken 193 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 188 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
211 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25464 {
25465 18 walkdown2(COOLSCROLL);
25466 18 }
25467
25468 315 show_subscreen_life=true;
25469 315 show_subscreen_numbers=true;
25470 315 playLevelMusic();
25471 315 currcset=DMaps[currdmap].color;
25472 315 dointro();
25473 315 newscr_clk=frame;
25474 315 activated_timed_warp=false;
25475 315 dir=down;
25476 315 set_respawn_point();
25477 315 eat_buttons();
25478 315 didstuff=0;
25479 315 usecounts.clear();
25480 315 map_bkgsfx(true);
25481 315 loadside=dir^1;
25482 315 }
25483
25484
25485 5783 void HeroClass::stepforward(int32_t steps, bool adjust)
25486 {
25487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5783 times.
5783 if ( FFCore.nostepforward ) return;
25488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5783 times.
5783 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
25489 5783 zfix tx=x; //temp x
25490 5783 zfix ty=y; //temp y
25491 5783 zfix tstep(0); //temp single step distance
25492 5783 zfix s(0); //calculated step distance for all steps
25493 5783 z3step=2;
25494 5783 int32_t sh=shiftdir;
25495 5783 shiftdir=-1;
25496
25497
2/2
✓ Branch 0 taken 98942 times.
✓ Branch 1 taken 5783 times.
104725 for(int32_t i=steps; i>0; --i)
25498 {
25499
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 98931 times.
98942 if(diagonalMovement)
25500 {
25501
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25502 {
25503 11 tstep = 1.5;
25504 11 }
25505 else
25506 {
25507 tstep=z3step;
25508 z3step=(z3step%2)+1;
25509 }
25510 11 }
25511 else
25512 {
25513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98931 times.
98931 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
25514 {
25515 tstep = 1.5;
25516 }
25517 else
25518 {
25519
2/2
✓ Branch 0 taken 55707 times.
✓ Branch 1 taken 43224 times.
98931 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
25520
25521
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 31402 times.
✓ Branch 2 taken 24305 times.
✓ Branch 3 taken 19261 times.
✓ Branch 4 taken 23963 times.
98931 switch(dir)
25522 {
25523 case up:
25524 31402 ty-=tstep;
25525 31402 break;
25526
25527 case down:
25528 24305 ty+=tstep;
25529 24305 break;
25530
25531 case left:
25532 19261 tx-=tstep;
25533 19261 break;
25534
25535 case right:
25536 23963 tx+=tstep;
25537 23963 break;
25538 }
25539 }
25540 }
25541
25542 98942 s+=tstep;
25543 98942 }
25544
25545 5783 z3step=2;
25546
25547 5783 x = x.getInt();
25548 5783 y = y.getInt();
25549
2/2
✓ Branch 0 taken 104629 times.
✓ Branch 1 taken 5783 times.
110412 while(s>=0)
25550 {
25551
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104617 times.
104629 if(diagonalMovement)
25552 {
25553
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
12 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
25554 {
25555 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25556 {
25557 walkable = false;
25558 shiftdir = -1;
25559 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25560 switch(tdir)
25561 {
25562 case left:
25563 --x;
25564 break;
25565 case right:
25566 ++x;
25567 break;
25568 case up:
25569 --y;
25570 break;
25571 case down:
25572 ++y;
25573 break;
25574 }
25575 }
25576 else
25577 {
25578 walkable=false;
25579 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25580 moveOld2(dir, 150);
25581 }
25582 }
25583 else
25584 {
25585
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25586 {
25587 12 s-=1.5;
25588 12 }
25589 else
25590 {
25591 s-=z3step;
25592 }
25593 12 walkable=true;
25594 12 moveOld2(dir, 150);
25595 }
25596
25597 12 shiftdir=-1;
25598 12 }
25599 else
25600 {
25601
3/6
✓ Branch 0 taken 58990 times.
✓ Branch 1 taken 45627 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104617 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104617 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
25602 {
25603 walkable=false;
25604 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25605 switch(tdir)
25606 {
25607 case left:
25608 --x;
25609 break;
25610 case right:
25611 ++x;
25612 break;
25613 case up:
25614 --y;
25615 break;
25616 case down:
25617 ++y;
25618 break;
25619 }
25620 }
25621 else
25622 {
25623
2/4
✓ Branch 0 taken 104617 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104617 times.
104617 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25624 {
25625 s-=1.5;
25626 }
25627
2/2
✓ Branch 0 taken 58990 times.
✓ Branch 1 taken 45627 times.
104617 else if(dir<left)
25628 {
25629 58990 s-=lsteps[y.getInt()&7];
25630 58990 }
25631 else
25632 {
25633 45627 s-=lsteps[x.getInt()&7];
25634 }
25635
25636 104617 moveOld2(dir, 150);
25637 }
25638 }
25639
25640
2/2
✓ Branch 0 taken 98846 times.
✓ Branch 1 taken 5783 times.
104629 if(s<0)
25641 {
25642 // Not quite sure how this is actually supposed to work.
25643 // There have to be two cases for each direction or Hero
25644 // either walks too far onto the screen or may get stuck
25645 // going through walk-through walls.
25646
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2110 times.
✓ Branch 2 taken 1268 times.
✓ Branch 3 taken 1049 times.
✓ Branch 4 taken 1356 times.
5783 switch(dir)
25647 {
25648 case up:
25649
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1974 times.
2110 if(y<8) // Leaving the screen
25650 136 y+=s;
25651 else // Entering the screen
25652 1974 y-=s;
25653
25654 2110 break;
25655
25656 case down:
25657
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1153 times.
1268 if(y>152)
25658 115 y-=s;
25659 else
25660 1153 y+=s;
25661
25662 1268 break;
25663
25664 case left:
25665
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 948 times.
1049 if(x<8)
25666 101 x+=s;
25667 else
25668 948 x-=s;
25669
25670 1049 break;
25671
25672 case right:
25673
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1241 times.
1356 if(x>=232)
25674 115 x-=s;
25675 else
25676 1241 x+=s;
25677
25678 1356 break;
25679 }
25680 5783 }
25681
25682
25683 104629 draw_screen(tmpscr);
25684
1/2
✓ Branch 0 taken 104629 times.
✗ Branch 1 not taken.
104629 if (canSideviewLadder()) setOnSideviewLadder(true);
25685 104629 advanceframe(true);
25686
25687
1/2
✓ Branch 0 taken 104629 times.
✗ Branch 1 not taken.
104629 if(Quit)
25688 return;
25689 }
25690
4/4
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1356 times.
✓ Branch 2 taken 1268 times.
✓ Branch 3 taken 3159 times.
5783 if(dir==right||dir==down)
25691 {
25692 2624 x=int32_t(x);
25693 2624 y=int32_t(y);
25694 2624 }
25695 else
25696 {
25697 3159 x = x.getInt();
25698 3159 y = y.getInt();
25699 }
25700 5783 set_respawn_point();
25701 5783 draw_screen(tmpscr);
25702 5783 eat_buttons();
25703 5783 shiftdir=sh;
25704 5783 }
25705
25706 228 void HeroClass::walkdown(bool opening) //entering cave
25707 {
25708
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 198 times.
228 if(opening)
25709 {
25710 198 close_black_opening(x+8, y+8+playing_field_offset, false);
25711 198 }
25712
25713 228 hclk=0;
25714 228 stop_item_sfx(itype_brang);
25715 228 sfx(WAV_STAIRS,pan(x.getInt()));
25716 228 clk=0;
25717 // int32_t cmby=(y.getInt()&0xF0)+16;
25718 // Fix Hero's position to the grid
25719 228 y=y.getInt()&0xF0;
25720 228 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
25721 228 attack=wNone;
25722 228 attackid=-1;
25723 228 reset_swordcharge();
25724 228 climb_cover_x=x.getInt()&0xF0;
25725 228 climb_cover_y=(y.getInt()&0xF0)+16;
25726
25727 228 guys.clear();
25728 228 chainlinks.clear();
25729 228 Lwpns.clear();
25730 228 Ewpns.clear();
25731 228 items.clear();
25732
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 14592 times.
14820 for(int32_t i=0; i<64; i++)
25733 {
25734 14592 herostep();
25735
25736
2/4
✓ Branch 0 taken 14592 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14592 times.
14592 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25737 hero_count=(hero_count+1)%16;
25738
25739
2/2
✓ Branch 0 taken 10944 times.
✓ Branch 1 taken 3648 times.
14592 if((i&3)==3)
25740 3648 ++y;
25741
25742 14592 draw_screen(tmpscr);
25743 14592 advanceframe(true);
25744
25745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14592 times.
14592 if(Quit)
25746 break;
25747 14592 }
25748
25749 228 action=none; FFCore.setHeroAction(none);
25750 228 }
25751
25752 21 void HeroClass::walkdown2(bool opening) //exiting cave 2
25753 {
25754 21 int32_t type = combobuf[MAPCOMBO(x,y)].type;
25755
25756
25757 // Fix Hero's position to the grid
25758 21 y=y.getInt()&0xF0;
25759
25760
2/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
25761 y -= 16;
25762
25763 21 climb_cover_x=x.getInt()&0xF0;
25764 21 climb_cover_y=y.getInt()&0xF0;
25765
25766 21 dir=down;
25767 21 z=fakez=fall=fakefall=0;
25768
25769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(opening)
25770 {
25771 21 open_black_opening(x+8, y+8+playing_field_offset+16, false);
25772 21 }
25773
25774 21 hclk=0;
25775 21 stop_item_sfx(itype_brang);
25776 21 sfx(WAV_STAIRS,pan(x.getInt()));
25777 21 clk=0;
25778 21 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
25779 21 attack=wNone;
25780 21 attackid=-1;
25781 21 reset_swordcharge();
25782
25783 21 guys.clear();
25784 21 chainlinks.clear();
25785 21 Lwpns.clear();
25786 21 Ewpns.clear();
25787 21 items.clear();
25788
25789
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1344 times.
1365 for(int32_t i=0; i<64; i++)
25790 {
25791 1344 herostep();
25792
25793
2/4
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1344 times.
1344 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25794 hero_count=(hero_count+1)%16;
25795
25796
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 if((i&3)==3)
25797 336 ++y;
25798
25799 1344 draw_screen(tmpscr);
25800 1344 advanceframe(true);
25801
25802
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(Quit)
25803 break;
25804 1344 }
25805
25806
25807 21 action=none; FFCore.setHeroAction(none);
25808 21 }
25809
25810 196 void HeroClass::walkup(bool opening) //exiting cave
25811 {
25812 196 int32_t type = combobuf[MAPCOMBO(x,y)].type;
25813
25814
4/6
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 188 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
196 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
25815 y+=16;
25816
25817 // Fix Hero's position to the grid
25818 196 y=y.getInt()&0xF0;
25819 196 z=fakez=fall=fakefall=0;
25820
25821
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 174 times.
196 if(opening)
25822 {
25823 174 open_black_opening(x+8, y+8+playing_field_offset-16, false);
25824 174 }
25825
25826 196 hclk=0;
25827 196 stop_item_sfx(itype_brang);
25828 196 sfx(WAV_STAIRS,pan(x.getInt()));
25829 196 dir=down;
25830 196 clk=0;
25831 // int32_t cmby=y.getInt()&0xF0;
25832 196 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
25833 196 attack=wNone;
25834 196 attackid=-1;
25835 196 reset_swordcharge();
25836 196 climb_cover_x=x.getInt()&0xF0;
25837 196 climb_cover_y=y.getInt()&0xF0;
25838
25839 196 guys.clear();
25840 196 chainlinks.clear();
25841 196 Lwpns.clear();
25842 196 Ewpns.clear();
25843 196 items.clear();
25844
25845
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 12544 times.
12740 for(int32_t i=0; i<64; i++)
25846 {
25847 12544 herostep();
25848
25849
2/4
✓ Branch 0 taken 12544 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12544 times.
12544 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25850 hero_count=(hero_count+1)%16;
25851
25852
2/2
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 3136 times.
12544 if((i&3)==0)
25853 3136 --y;
25854
25855 12544 draw_screen(tmpscr);
25856 12544 advanceframe(true);
25857
25858
1/2
✓ Branch 0 taken 12544 times.
✗ Branch 1 not taken.
12544 if(Quit)
25859 break;
25860 12544 }
25861 196 map_bkgsfx(true);
25862 196 loadside=dir^1;
25863 196 action=none; FFCore.setHeroAction(none);
25864 196 }
25865
25866 114 void HeroClass::walkup2(bool opening) //entering cave2
25867 {
25868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(opening)
25869 {
25870 114 close_black_opening(x+8, y+8+playing_field_offset, false);
25871 114 }
25872
25873 114 hclk=0;
25874 114 stop_item_sfx(itype_brang);
25875 114 sfx(WAV_STAIRS,pan(x.getInt()));
25876 114 dir=up;
25877 114 clk=0;
25878 // int32_t cmby=y.getInt()&0xF0;
25879 114 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
25880 114 attack=wNone;
25881 114 attackid=-1;
25882 114 reset_swordcharge();
25883 114 climb_cover_x=x.getInt()&0xF0;
25884 114 climb_cover_y=(y.getInt()&0xF0)-16;
25885
25886 114 guys.clear();
25887 114 chainlinks.clear();
25888 114 Lwpns.clear();
25889 114 Ewpns.clear();
25890 114 items.clear();
25891
25892
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 7296 times.
7410 for(int32_t i=0; i<64; i++)
25893 {
25894 7296 herostep();
25895
25896
2/4
✓ Branch 0 taken 7296 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7296 times.
7296 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25897 hero_count=(hero_count+1)%16;
25898
25899
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 if((i&3)==0)
25900 1824 --y;
25901
25902 7296 draw_screen(tmpscr);
25903 7296 advanceframe(true);
25904
25905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7296 times.
7296 if(Quit)
25906 break;
25907 7296 }
25908 114 map_bkgsfx(true);
25909 114 loadside=dir^1;
25910 114 action=none; FFCore.setHeroAction(none);
25911 114 }
25912
25913 325 void HeroClass::stepout() // Step out of item cellars and passageways
25914 {
25915 325 int32_t sc = specialcave; // This gets erased by ALLOFF()
25916 325 ALLOFF();
25917 325 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25918 325 map_bkgsfx(false);
25919 325 kill_enemy_sfx();
25920 325 draw_screen(tmpscr,false);
25921 325 fade(sc>=GUYCAVE?10:11,true,false);
25922 325 blackscr(30,true);
25923 325 ringcolor(false);
25924
25925
4/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 142 times.
✓ Branch 3 taken 183 times.
325 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
25926 {
25927 183 currdmap=stepoutdmap;
25928 183 currmap=DMaps[currdmap].map;
25929 183 dlevel=DMaps[currdmap].level;
25930
25931 //we might have just left a passage, so be sure to update the CSet record -DD
25932 183 currcset=DMaps[currdmap].color;
25933
25934 183 init_dmap();
25935 183 homescr=stepoutscr;
25936 183 }
25937
25938 325 currscr=homescr;
25939 325 loadscr(0,currdmap,currscr,255,false); // bogus direction
25940 325 draw_screen(tmpscr,false);
25941
25942
3/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✓ Branch 3 taken 6 times.
325 if(get_bit(quest_rules, qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
25943 {
25944 319 darkroom = naturaldark = false;
25945 319 fade(DMaps[currdmap].color,true,true);
25946 319 }
25947 else
25948 {
25949 6 darkroom = naturaldark = true;
25950
25951
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if(get_bit(quest_rules,qr_FADE))
25952 {
25953 4 interpolatedfade();
25954 4 }
25955 else
25956 {
25957 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
25958 }
25959 6 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
25960 6 si+=3*48;
25961
25962
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<16; i++)
25963 {
25964 96 RAMpal[CSET(9)+i] = _RGB(si);
25965 96 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
25966 96 si+=3;
25967 96 }
25968 }
25969
25970 325 x = tmpscr->warpreturnx[stepoutwr];
25971 325 y = tmpscr->warpreturny[stepoutwr];
25972
25973
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 if(didpit)
25974 {
25975 didpit=false;
25976 x=pitx;
25977 y=pity;
25978 }
25979
25980
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 309 times.
325 if(x+y == 0)
25981 16 x = y = 80;
25982
25983 325 dir=down;
25984
25985 325 set_respawn_point();
25986
25987 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
25988 325 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
25989
25990
4/6
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 320 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
325 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
25991 {
25992 walkup(false);
25993 }
25994
4/6
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 320 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
325 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
25995 {
25996 walkdown2(false);
25997 }
25998
25999 325 newscr_clk=frame;
26000 325 activated_timed_warp=false;
26001 325 didstuff=0;
26002 325 usecounts.clear();
26003 325 eat_buttons();
26004 325 markBmap(-1);
26005 325 map_bkgsfx(true);
26006
26007
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 27 times.
325 if(!get_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC))
26008 {
26009 27 music_stop();
26010 27 playLevelMusic();
26011 27 }
26012
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 else if(get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC))
26013 {
26014 playLevelMusic();
26015 }
26016
26017 325 loadside=dir^1;
26018 325 }
26019
26020 12639 bool HeroClass::nextcombo_wf(int32_t d2)
26021 {
26022
6/8
✓ Branch 0 taken 12588 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 12342 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 12342 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 246 times.
✗ Branch 7 not taken.
12639 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
26023 12639 return false;
26024
26025 // assumes Hero is about to scroll screens
26026
26027 int32_t ns = nextscr(d2);
26028
26029 if(ns==0xFFFF)
26030 return false;
26031
26032 // want actual screen index, not game->maps[] index
26033 ns = (ns&127) + (ns>>7)*MAPSCRS;
26034
26035 int32_t cx = x;
26036 int32_t cy = y;
26037
26038 switch(d2)
26039 {
26040 case up:
26041 cy=160;
26042 break;
26043
26044 case down:
26045 cy=0;
26046 break;
26047
26048 case left:
26049 cx=240;
26050 break;
26051
26052 case right:
26053 cx=0;
26054 break;
26055 }
26056
26057 // check lower half of combo
26058 cy += 8;
26059
26060 // from MAPCOMBO()
26061 int32_t cmb = (cy&0xF0)+(cx>>4);
26062
26063 if(cmb>175)
26064 return true;
26065
26066 newcombo c = combobuf[TheMaps[ns].data[cmb]];
26067 bool dried = iswater_type(c.type) && DRIEDLAKE;
26068 bool swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
26069 int32_t b=1;
26070
26071 if(cx&8) b<<=2;
26072
26073 if(cy&8) b<<=1;
26074
26075 if((c.walk&b) && !dried && !swim)
26076 return true;
26077
26078 // next block (i.e. cnt==2)
26079 if(!(cx&8))
26080 {
26081 b<<=2;
26082 }
26083 else
26084 {
26085 c = combobuf[TheMaps[ns].data[++cmb]];
26086 dried = iswater_type(c.type) && DRIEDLAKE;
26087 swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
26088 b=1;
26089
26090 if(cy&8)
26091 {
26092 b<<=1;
26093 }
26094 }
26095
26096 return (c.walk&b) ? !dried && !swim : false;
26097 12639 }
26098
26099 bool HeroClass::nextcombo_solid(int32_t d2)
26100 {
26101 if(toogam || currscr>=128)
26102 return false;
26103
26104 // assumes Hero is about to scroll screens
26105
26106 int32_t ns = nextscr(d2);
26107
26108 if(ns==0xFFFF)
26109 return false;
26110
26111 // want actual screen index, not game->maps[] index
26112 ns = (ns&127) + (ns>>7)*MAPSCRS;
26113 int32_t screen = (ns%MAPSCRS);
26114 int32_t map = (ns - screen) / MAPSCRS;
26115
26116 int32_t cx = x;
26117 int32_t cy = y;
26118
26119 switch(d2)
26120 {
26121 case up:
26122 cy=160;
26123 break;
26124
26125 case down:
26126 cy=0;
26127 break;
26128
26129 case left:
26130 cx=240;
26131 break;
26132
26133 case right:
26134 cx=0;
26135 break;
26136 }
26137
26138 if(d2==up) cy += 8;
26139
26140 if(d2==left||d2==right) cy+=bigHitbox?0:8;
26141
26142 int32_t initcx = cx;
26143 int32_t initcy = cy;
26144 // from MAPCOMBO()
26145
26146 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
26147 {
26148 cx = initcx;
26149 for(int32_t k=0; k<=(get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
26150 {
26151 int32_t cmb = (cy&0xF0)+(cx>>4);
26152
26153 if(cmb>175)
26154 {
26155 return true;
26156 }
26157
26158 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))];
26159
26160 int32_t b=1;
26161
26162 if(cx&8) b<<=2;
26163
26164 if(cy&8) b<<=1;
26165
26166 //bool bridgedetected = false;
26167
26168 int32_t walk = c.walk;
26169 if (get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))
26170 {
26171 for (int32_t m = 0; m <= 1; m++)
26172 {
26173 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
26174 if (cmb.type == cBRIDGE)
26175 {
26176 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
26177 {
26178 int efflag = (cmb.walk & 0xF0)>>4;
26179 int newsolid = (cmb.walk & 0xF);
26180 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
26181 }
26182 else walk &= cmb.walk;
26183 }
26184 else walk |= cmb.walk;
26185 }
26186 }
26187 /*
26188 if (bridgedetected)
26189 {
26190 continue;
26191 }*/
26192
26193 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
26194 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
26195
26196 if((walk&b) && !swim)
26197 {
26198 return true;
26199 }
26200 }
26201
26202 /*
26203 #if 0
26204
26205 //
26206 // next block (i.e. cnt==2)
26207 if(!(cx&8))
26208 {
26209 b<<=2;
26210 }
26211 else
26212 {
26213 c = combobuf[TheMaps[ns].data[++cmb]];
26214 dried = iswater_type(c.type) && DRIEDLAKE;
26215 //swim = iswater_type(c.type) && (current_item(itype_flippers));
26216 b=1;
26217
26218 if(cy&8)
26219 {
26220 b<<=1;
26221 }
26222 }
26223
26224 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26225
26226 if((c.walk&b) && !dried && !swim)
26227 {
26228 return true;
26229 }
26230
26231 cx+=8;
26232
26233 if(cx&7)
26234 {
26235 if(!(cx&8))
26236 {
26237 b<<=2;
26238 }
26239 else
26240 {
26241 c = combobuf[TheMaps[ns].data[++cmb]];
26242 dried = iswater_type(c.type) && DRIEDLAKE;
26243 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26244 b=1;
26245
26246 if(cy&8)
26247 {
26248 b<<=1;
26249 }
26250 }
26251
26252 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26253
26254 if((c.walk&b) && !dried && !swim)
26255 return true;
26256 }
26257
26258 #endif
26259 */
26260 }
26261
26262 return false;
26263 }
26264
26265 6418211 void HeroClass::checkscroll()
26266 {
26267 //DO NOT scroll if Hero is vibrating due to Divine Escape effect -DD
26268
2/4
✓ Branch 0 taken 6418211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6418211 times.
✗ Branch 3 not taken.
6418211 if(action == casting||action==sideswimcasting)
26269 return;
26270
26271
2/2
✓ Branch 0 taken 6404805 times.
✓ Branch 1 taken 13406 times.
6418211 if(toogam)
26272 {
26273
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(x<0 && (currscr&15)==0) x=0;
26274
26275
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13386 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
13406 if(y<0 && currscr<16) y=0;
26276
26277
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13391 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
13406 if(x>240 && (currscr&15)==15) x=240;
26278
26279
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(y>160 && currscr>=112) y=160;
26280 13406 }
26281
26282
2/2
✓ Branch 0 taken 6414821 times.
✓ Branch 1 taken 3390 times.
6418211 if(y<0)
26283 {
26284 3390 bool doit=true;
26285 3390 y=0;
26286
26287
4/6
✓ Branch 0 taken 3389 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3389 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3388 times.
3390 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26288 doit = false;
26289
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3388 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26290 doit = false;
26291
26292
1/2
✓ Branch 0 taken 3388 times.
✗ Branch 1 not taken.
3388 if(nextcombo_wf(up))
26293 doit=false;
26294
26295
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3388 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
26296 {
26297 if(nextcombo_solid(up))
26298 doit=false;
26299 }
26300
26301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3388 if(doit || action==inwind)
26302 {
26303
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 3063 times.
3388 if(currscr>=128)
26304 {
26305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 325 times.
325 if(specialcave >= GUYCAVE)
26306 exitcave();
26307 325 else stepout();
26308 325 }
26309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3063 times.
3063 else if(action==inwind)
26310 {
26311 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26312 {
26313 action=none; FFCore.setHeroAction(none);
26314 restart_level();
26315 }
26316 else
26317 {
26318 dowarp(2,up);
26319 }
26320 }
26321
3/6
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 2989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3063 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26322 {
26323 74 sdir=up;
26324 74 dowarp(1,(tmpscr->sidewarpindex)&3);
26325 74 }
26326
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2981 times.
2989 else if(!edge_of_dmap(up))
26327 {
26328 2981 scrolling_map = currmap;
26329 2981 scrollscr(up);
26330
26331
1/2
✓ Branch 0 taken 2981 times.
✗ Branch 1 not taken.
2981 if(tmpscr->flags4&fAUTOSAVE)
26332 {
26333 save_game(true,0);
26334 }
26335
26336
2/2
✓ Branch 0 taken 2977 times.
✓ Branch 1 taken 4 times.
2981 if(tmpscr->flags6&fCONTINUEHERE)
26337 {
26338 4 lastentrance_dmap = currdmap;
26339 4 lastentrance = homescr;
26340 4 }
26341 2981 }
26342 3388 }
26343 3388 }
26344
26345
2/2
✓ Branch 0 taken 6415610 times.
✓ Branch 1 taken 2599 times.
6418209 if(y>160)
26346 {
26347 2599 bool doit=true;
26348 2599 y=160;
26349
26350
5/6
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 2560 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 2559 times.
2599 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26351 40 doit = false;
26352
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2599 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2599 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26353 doit = false;
26354
26355
1/2
✓ Branch 0 taken 2599 times.
✗ Branch 1 not taken.
2599 if(nextcombo_wf(down))
26356 doit=false;
26357
26358
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2599 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2599 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
26359 {
26360 if(nextcombo_solid(down))
26361 doit=false;
26362 }
26363
26364
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
2599 if(doit || action==inwind)
26365 {
26366
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 2300 times.
2559 if(currscr>=128)
26367 {
26368
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 if(specialcave >= GUYCAVE)
26369 259 exitcave();
26370 else stepout();
26371 259 }
26372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2300 times.
2300 else if(action==inwind)
26373 {
26374 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26375 {
26376 action=none; FFCore.setHeroAction(none);
26377 restart_level();
26378 }
26379 else
26380 {
26381 dowarp(2,down);
26382 }
26383 }
26384
3/6
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 2125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2300 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26385 {
26386 175 sdir=down;
26387 175 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
26388 175 }
26389
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2120 times.
2125 else if(!edge_of_dmap(down))
26390 {
26391 2120 scrolling_map = currmap;
26392 2120 scrollscr(down);
26393
26394
1/2
✓ Branch 0 taken 2120 times.
✗ Branch 1 not taken.
2120 if(tmpscr->flags4&fAUTOSAVE)
26395 {
26396 save_game(true,0);
26397 }
26398
26399
2/2
✓ Branch 0 taken 2118 times.
✓ Branch 1 taken 2 times.
2120 if(tmpscr->flags6&fCONTINUEHERE)
26400 {
26401 2 lastentrance_dmap = currdmap;
26402 2 lastentrance = homescr;
26403 2 }
26404 2120 }
26405 2559 }
26406 2599 }
26407
26408
2/2
✓ Branch 0 taken 6415567 times.
✓ Branch 1 taken 2642 times.
6418209 if(x<0)
26409 {
26410 2642 bool doit=true;
26411 2642 x=0;
26412
26413
5/6
✓ Branch 0 taken 2634 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2634 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 2632 times.
2642 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26414 8 doit = false;
26415
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2639 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2640 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26416 doit = false;
26417
26418
1/2
✓ Branch 0 taken 2640 times.
✗ Branch 1 not taken.
2640 if(nextcombo_wf(left))
26419 doit=false;
26420
26421
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2640 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
26422 {
26423 if(nextcombo_solid(left))
26424 doit=false;
26425 }
26426
26427
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2632 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 9 times.
2640 if(doit || action==inwind)
26428 {
26429
1/2
✓ Branch 0 taken 2633 times.
✗ Branch 1 not taken.
2633 if(currscr>=128)
26430 {
26431 if(specialcave >= GUYCAVE)
26432 exitcave();
26433 else stepout();
26434 }
26435
26436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2633 times.
2633 if(action==inwind)
26437 {
26438 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26439 {
26440 action=none; FFCore.setHeroAction(none);
26441 restart_level();
26442 }
26443 else
26444 {
26445 dowarp(2,left);
26446 }
26447 }
26448
3/6
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2540 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2633 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26449 {
26450 93 sdir=left;
26451 93 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
26452 93 }
26453
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 2451 times.
2540 else if(!edge_of_dmap(left))
26454 {
26455 2451 scrolling_map = currmap;
26456 2451 scrollscr(left);
26457
26458
1/2
✓ Branch 0 taken 2451 times.
✗ Branch 1 not taken.
2451 if(tmpscr->flags4&fAUTOSAVE)
26459 {
26460 save_game(true,0);
26461 }
26462
26463
2/2
✓ Branch 0 taken 2443 times.
✓ Branch 1 taken 8 times.
2451 if(tmpscr->flags6&fCONTINUEHERE)
26464 {
26465 8 lastentrance_dmap = currdmap;
26466 8 lastentrance = homescr;
26467 8 }
26468 2451 }
26469 2633 }
26470 2642 }
26471
26472
2/2
✓ Branch 0 taken 6415162 times.
✓ Branch 1 taken 3045 times.
6418207 if(x>240)
26473 {
26474 3045 bool doit=true;
26475 3045 x=240;
26476
26477
3/6
✓ Branch 0 taken 3045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3045 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3045 times.
3045 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
26478 doit = false;
26479
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3045 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3045 if(lift_wpn && get_bit(quest_rules,qr_NO_SCROLL_WHILE_CARRYING))
26480 doit = false;
26481
26482
1/2
✓ Branch 0 taken 3045 times.
✗ Branch 1 not taken.
3045 if(nextcombo_wf(right))
26483 doit=false;
26484
26485
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3045 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3045 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
26486 {
26487 if(nextcombo_solid(right))
26488 doit=false;
26489 }
26490
26491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3045 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3045 if(doit || action==inwind)
26492 {
26493
1/2
✓ Branch 0 taken 3045 times.
✗ Branch 1 not taken.
3045 if(currscr>=128)
26494 {
26495 if(specialcave >= GUYCAVE)
26496 exitcave();
26497 else stepout();
26498 }
26499
26500
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 2978 times.
3045 if(action==inwind)
26501 {
26502
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 66 times.
67 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26503 {
26504 1 action=none; FFCore.setHeroAction(none);
26505 1 restart_level();
26506 1 }
26507 else
26508 {
26509 66 dowarp(2,right);
26510 }
26511 67 }
26512
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2876 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2978 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26513 {
26514 102 sdir=right;
26515 102 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
26516 102 }
26517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2876 times.
2876 else if(!edge_of_dmap(right))
26518 {
26519 2876 scrolling_map = currmap;
26520 2876 scrollscr(right);
26521
26522
1/2
✓ Branch 0 taken 2876 times.
✗ Branch 1 not taken.
2876 if(tmpscr->flags4&fAUTOSAVE)
26523 {
26524 save_game(true,0);
26525 }
26526
26527
2/2
✓ Branch 0 taken 2866 times.
✓ Branch 1 taken 10 times.
2876 if(tmpscr->flags6&fCONTINUEHERE)
26528 {
26529 10 lastentrance_dmap = currdmap;
26530 10 lastentrance = homescr;
26531 10 }
26532 2876 }
26533 3045 }
26534 3045 }
26535 6418207 }
26536
26537 // assumes current direction is in lastdir[3]
26538 // compares directions with scr->path and scr->exitdir
26539 31281 bool HeroClass::checkmaze(mapscr *scr, bool sound)
26540 {
26541
2/2
✓ Branch 0 taken 30930 times.
✓ Branch 1 taken 351 times.
31281 if(!(scr->flags&fMAZE))
26542 30930 return true;
26543
26544
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 305 times.
351 if(lastdir[3]==scr->exitdir)
26545 46 return true;
26546
26547
2/2
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 44 times.
523 for(int32_t i=0; i<4; i++)
26548
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 261 times.
479 if(lastdir[i]!=scr->path[i])
26549 261 return false;
26550
26551
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 22 times.
44 if(sound)
26552 22 sfx(scr->secretsfx);
26553
26554 44 return true;
26555 31281 }
26556
26557 20852 bool HeroClass::edge_of_dmap(int32_t side)
26558 {
26559
2/2
✓ Branch 0 taken 20699 times.
✓ Branch 1 taken 153 times.
20852 if(checkmaze(tmpscr,false)==false)
26560 153 return false;
26561
26562 // needs fixin'
26563 // should check dmap style
26564
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5877 times.
✓ Branch 2 taken 4197 times.
✓ Branch 3 taken 4934 times.
✓ Branch 4 taken 5691 times.
20699 switch(side)
26565 {
26566 case up:
26567 5877 return currscr<16;
26568
26569 case down:
26570 4197 return currscr>=112;
26571
26572 case left:
26573
2/2
✓ Branch 0 taken 4845 times.
✓ Branch 1 taken 89 times.
4934 if((currscr&15)==0)
26574 89 return true;
26575
26576
2/2
✓ Branch 0 taken 2574 times.
✓ Branch 1 taken 2271 times.
4845 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
26577 // if(dlevel)
26578 2574 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
26579
26580 2271 break;
26581
26582 case right:
26583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5691 times.
5691 if((currscr&15)==15)
26584 return true;
26585
26586
2/2
✓ Branch 0 taken 3205 times.
✓ Branch 1 taken 2486 times.
5691 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
26587 // if(dlevel)
26588 3205 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
26589
26590 2486 break;
26591 }
26592
26593 4757 return false;
26594 20852 }
26595
26596 196 bool HeroClass::lookaheadraftflag(int32_t d2)
26597 {
26598 // Helper for scrollscr that gets next combo on next screen.
26599 // Can use destscr for scrolling warps,
26600 // but assumes currmap is correct.
26601
26602 196 int32_t cx = x;
26603 196 int32_t cy = y + 8;
26604
26605 196 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26606 196 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26607 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26608 //Applying this here, too. -Z
26609
26610
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 57 times.
196 switch(d2)
26611 {
26612 case up:
26613 51 cy=160;
26614 51 break;
26615
26616 case down:
26617 41 cy=0;
26618 41 break;
26619
26620 case left:
26621 47 cx=240;
26622 47 break;
26623
26624 case right:
26625 57 cx=0;
26626 57 break;
26627 }
26628
26629 196 int32_t combo = (cy&0xF0)+(cx>>4);
26630
26631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 if(combo>175)
26632 return 0;
26633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
26634
26635 196 }
26636 10743 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
26637 {
26638 // Can use destscr for scrolling warps,
26639 // but assumes currmap is correct.
26640
26641 10743 int32_t cx = vbound(x,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
26642 10743 int32_t cy = vbound(y + 8,0,160);
26643 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26644 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26645 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26646
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 2174 times.
✓ Branch 3 taken 2518 times.
✓ Branch 4 taken 3024 times.
10743 switch(d2)
26647 {
26648 case up:
26649 3027 cy=160;
26650 3027 break;
26651
26652 case down:
26653 2174 cy=0;
26654 2174 break;
26655
26656 case left:
26657 2518 cx=240;
26658 2518 break;
26659
26660 case right:
26661 3024 cx=0;
26662 3024 break;
26663 }
26664
26665 10743 int32_t combo = (cy&0xF0)+(cx>>4);
26666
26667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10743 times.
10743 if(combo>175)
26668 return 0;
26669
26670 10743 return tmpscr[0].data[combo]; // entire combo code
26671 10743 }
26672
26673 10743 int32_t HeroClass::lookaheadflag(int32_t d2)
26674 {
26675 // Helper for scrollscr that gets next combo on next screen.
26676 // Can use destscr for scrolling warps,
26677 // but assumes currmap is correct.
26678
26679 10743 int32_t cx = vbound(x,0,240);
26680 10743 int32_t cy = vbound(y + 8,0,160);
26681
26682 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26683 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26684 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26685 //Applying this here, too. -Z
26686
26687
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 2174 times.
✓ Branch 3 taken 2518 times.
✓ Branch 4 taken 3024 times.
10743 switch(d2)
26688 {
26689 case up:
26690 3027 cy=160;
26691 3027 break;
26692
26693 case down:
26694 2174 cy=0;
26695 2174 break;
26696
26697 case left:
26698 2518 cx=240;
26699 2518 break;
26700
26701 case right:
26702 3024 cx=0;
26703 3024 break;
26704 }
26705
26706 10743 int32_t combo = (cy&0xF0)+(cx>>4);
26707
26708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10743 times.
10743 if(combo>175)
26709 return 0;
26710
26711
2/2
✓ Branch 0 taken 10464 times.
✓ Branch 1 taken 279 times.
10743 if(!tmpscr[0].sflag[combo])
26712 {
26713 10464 return combobuf[tmpscr[0].data[combo]].flag; // flag
26714 }
26715
26716 279 return tmpscr[0].sflag[combo]; // flag
26717 10743 }
26718
26719 1397763 void HeroClass::run_scrolling_script_int(bool waitdraw)
26720 {
26721
2/2
✓ Branch 0 taken 698761 times.
✓ Branch 1 taken 699002 times.
1397763 if(waitdraw)
26722 {
26723
3/4
✓ Branch 0 taken 698761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 602383 times.
✓ Branch 3 taken 96378 times.
698761 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
26724 {
26725 96378 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
26726 96378 global_wait&= ~(1<<GLOBAL_SCRIPT_GAME);
26727 96378 }
26728 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
26729
4/6
✓ Branch 0 taken 698761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 695354 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3407 times.
698761 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26730 {
26731 3407 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
26732 3407 player_waitdraw = false;
26733 3407 }
26734 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
26735
4/6
✓ Branch 0 taken 698761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 698727 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
698761 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26736 {
26737 34 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
26738 34 dmap_waitdraw = false;
26739 34 }
26740 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
26741
2/6
✓ Branch 0 taken 698761 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 698761 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
698761 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26742 {
26743 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
26744 passive_subscreen_waitdraw = false;
26745 }
26746 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
26747
4/10
✓ Branch 0 taken 698761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 698744 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
698761 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26748 {
26749 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
26750 tmpscr->screen_waitdraw = 0;
26751 }
26752 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
26753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 698761 times.
698761 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
26754 {
26755 698761 FFCore.itemScriptEngineOnWaitdraw();
26756 698761 }
26757 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
26758 698761 }
26759 else
26760 {
26761
4/8
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 698984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
699002 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26762 {
26763 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
26764 }
26765 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
26766
3/4
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549315 times.
✓ Branch 3 taken 149687 times.
699002 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (g_doscript & (1<<GLOBAL_SCRIPT_GAME)))
26767 {
26768 149687 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
26769 149687 }
26770 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
26771
5/6
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 689963 times.
✓ Branch 3 taken 9039 times.
✓ Branch 4 taken 686556 times.
✓ Branch 5 taken 3407 times.
699002 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && player_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
26772 {
26773 3407 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
26774 3407 }
26775 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
26776
4/6
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 699002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 686556 times.
✓ Branch 5 taken 12446 times.
699002 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26777 {
26778 12446 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
26779 12446 }
26780 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
26781
4/6
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 699002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 686556 times.
✓ Branch 5 taken 12446 times.
699002 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26782 {
26783 12446 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
26784 12446 }
26785 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
26786 699002 bool old = get_bit(quest_rules, qr_OLD_ITEMDATA_SCRIPT_TIMING);
26787
3/4
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6264 times.
✓ Branch 3 taken 692738 times.
699002 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
26788 692738 FFCore.itemScriptEngine();
26789 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
26790
3/4
✓ Branch 0 taken 699002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692738 times.
✓ Branch 3 taken 6264 times.
699002 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
26791 6264 FFCore.itemScriptEngine();
26792 }
26793 1397763 }
26794 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
26795 1397763 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
26796 {
26797 // For rafting (and possibly other esoteric things)
26798 // Hero's action should remain unchanged while scrolling,
26799 // but for the sake of scripts, here's an eye-watering kludge.
26800 1397763 actiontype lastaction = action;
26801 1397763 action=scrolling; FFCore.setHeroAction(scrolling);
26802
2/2
✓ Branch 0 taken 698761 times.
✓ Branch 1 taken 699002 times.
1397763 if(waitdraw)
26803 {
26804 698761 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
26805 698761 }
26806 else
26807 {
26808 699002 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
26809 }
26810 1397763 zfix storex = x, storey = y;
26811
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 348497 times.
✓ Branch 2 taken 237357 times.
✓ Branch 3 taken 367618 times.
✓ Branch 4 taken 444291 times.
1397763 switch(scrolldir)
26812 {
26813 case up:
26814
2/2
✓ Branch 0 taken 290295 times.
✓ Branch 1 taken 58202 times.
348497 if(y < 160) y = 176;
26815
4/4
✓ Branch 0 taken 49381 times.
✓ Branch 1 taken 8821 times.
✓ Branch 2 taken 18900 times.
✓ Branch 3 taken 30481 times.
58202 else if(cx > 0 && !end_frames) y = sy + 156;
26816 27721 else y = 160;
26817
26818 348497 break;
26819
26820 case down:
26821
2/2
✓ Branch 0 taken 196824 times.
✓ Branch 1 taken 40533 times.
237357 if(y > 0) y = -16;
26822
4/4
✓ Branch 0 taken 34123 times.
✓ Branch 1 taken 6410 times.
✓ Branch 2 taken 14133 times.
✓ Branch 3 taken 19990 times.
40533 else if(cx > 0 && !end_frames) y = sy - 172;
26823 20543 else y = 0;
26824
26825 237357 break;
26826
26827 case left:
26828
2/2
✓ Branch 0 taken 337768 times.
✓ Branch 1 taken 29850 times.
367618 if(x < 240) x = 256;
26829
2/2
✓ Branch 0 taken 24758 times.
✓ Branch 1 taken 5092 times.
29850 else if(cx > 0) x = sx + 236;
26830 5092 else x = 240;
26831
26832 367618 break;
26833
26834 case right:
26835
2/2
✓ Branch 0 taken 408267 times.
✓ Branch 1 taken 36024 times.
444291 if(x > 0) x = -16;
26836
2/2
✓ Branch 0 taken 29902 times.
✓ Branch 1 taken 6122 times.
36024 else if(cx > 0) x = sx - 252;
26837 6122 else x = 0;
26838
26839 444291 break;
26840 }
26841 1397763 run_scrolling_script_int(waitdraw);
26842
26843 1397763 x = storex, y = storey;
26844
26845 1397763 action=lastaction; FFCore.setHeroAction(lastaction);
26846 1397763 }
26847
26848 //Has solving the maze enabled a side warp?
26849 //Only used just before scrolling screens
26850 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
26851 // return true to abort the topmost scrollscr() call. -L
26852 10744 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
26853 {
26854
2/2
✓ Branch 0 taken 32232 times.
✓ Branch 1 taken 10744 times.
42976 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
26855
26856
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 10591 times.
10744 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
26857
26858
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10744 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
26859 {
26860 switch(scrolldir)
26861 {
26862 case up:
26863 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
26864 {
26865 lastdir[3] = 0xFF;
26866 sdir=up;
26867 dowarp(1,(tmpscr->sidewarpindex)&3);
26868 return true;
26869 }
26870
26871 break;
26872
26873 case down:
26874 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
26875 {
26876 lastdir[3] = 0xFF;
26877 sdir=down;
26878 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
26879 return true;
26880 }
26881
26882 break;
26883
26884 case left:
26885 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
26886 {
26887 lastdir[3] = 0xFF;
26888 sdir=left;
26889 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
26890 return true;
26891 }
26892
26893 break;
26894
26895 case right:
26896 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
26897 {
26898 lastdir[3] = 0xFF;
26899 sdir=right;
26900 dowarp(1,(tmpscr->sidewarpindex)&3);
26901 return true;
26902 }
26903
26904 break;
26905 }
26906 }
26907
26908 10744 return false;
26909 10744 }
26910
26911 10744 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
26912 {
26913 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
26914
2/2
✓ Branch 0 taken 636 times.
✓ Branch 1 taken 10108 times.
10744 if(get_bit(quest_rules, qr_VERYFASTSCROLLING))
26915 636 return 16;
26916
26917
2/2
✓ Branch 0 taken 9079 times.
✓ Branch 1 taken 1029 times.
10108 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0)
26918 {
26919
2/2
✓ Branch 0 taken 5121 times.
✓ Branch 1 taken 3958 times.
9079 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
26920 }
26921 else
26922 {
26923
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
26924 {
26925 482 return 8;
26926 }
26927 else
26928 {
26929
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 332 times.
547 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
26930 }
26931 }
26932 10744 }
26933
26934 10744 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
26935 {
26936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10744 times.
10744 if(get_bit(quest_rules, qr_NOSCROLL))
26937 return 0;
26938
26939
4/4
✓ Branch 0 taken 10108 times.
✓ Branch 1 taken 636 times.
✓ Branch 2 taken 9079 times.
✓ Branch 3 taken 1029 times.
10744 if( (get_bit(quest_rules, qr_VERYFASTSCROLLING) != 0) ||
26940 10108 (get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0) )
26941 {
26942 9715 return 1;
26943 }
26944 else
26945 {
26946
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
26947 {
26948
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 234 times.
482 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 4 : 2;
26949 }
26950 else
26951 {
26952 547 return 1;
26953 }
26954 }
26955 10744 }
26956
26957 5933 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
26958 {
26959 5933 int32_t lampid = current_item_id(itype_lantern);
26960
1/2
✓ Branch 0 taken 5933 times.
✗ Branch 1 not taken.
5933 if(lampid < 0) return;
26961 static bool lamp_paid = false;
26962
2/4
✓ Branch 0 taken 5933 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5933 times.
✗ Branch 3 not taken.
5933 if(!(checkbunny(lampid) && checkmagiccost(lampid,lamp_paid)))
26963 {
26964 lamp_paid = false;
26965 return;
26966 }
26967 5933 lamp_paid = true;
26968 5933 paymagiccost(lampid,false,true);
26969 5933 int32_t hx1 = x.getInt() - x1 + 8;
26970 5933 int32_t hy1 = y.getInt() - y1 + 8;
26971 5933 int32_t hx2 = x.getInt() - x2 + 8;
26972 5933 int32_t hy2 = y.getInt() - y2 + 8;
26973
26974 5933 itemdata& lamp = itemsbuf[lampid];
26975
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5545 times.
✓ Branch 2 taken 388 times.
5933 switch(lamp.misc1) //Shape
26976 {
26977 case 0: //Circle
26978 5545 doDarkroomCircle(hx1, hy1, lamp.misc2, darkscr_bmp_curscr);
26979 5545 doDarkroomCircle(hx2, hy2, lamp.misc2, darkscr_bmp_scrollscr);
26980 5545 break;
26981 case 1: //Lamp Cone
26982 388 doDarkroomCone(hx1, hy1, lamp.misc2, dir, darkscr_bmp_curscr);
26983 388 doDarkroomCone(hx2, hy2, lamp.misc2, dir, darkscr_bmp_scrollscr);
26984 388 break;
26985 }
26986 5933 }
26987
26988 10745 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
26989 {
26990
4/4
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 10745 times.
10745 if(action==freeze||action==sideswimfreeze)
26991 {
26992 2 return;
26993 }
26994
26995 10745 bool overlay = false;
26996
26997
3/4
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10744 times.
10745 if(scrolldir >= 0 && scrolldir <= 3)
26998 {
26999 10744 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
27000 10744 }
27001
27002
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 10429 times.
10745 if(destdmap == -1)
27003 {
27004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10429 times.
10429 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[currdmap].map].tileWidth
27005
1/2
✓ Branch 0 taken 10429 times.
✗ Branch 1 not taken.
10429 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[currdmap].map].tileHeight)
27006 return;
27007 10429 }
27008 else
27009 {
27010
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 316 times.
316 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[destdmap].map].tileWidth
27011
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 1 times.
316 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[destdmap].map].tileHeight)
27012 2 return;
27013 }
27014
27015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10745 times.
10745 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
27016 return;
27017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10745 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10745 bool isForceFaceUp = getOnSideviewLadder() && canSideviewLadder() &&
27018 !(jumping<0 || fall!=0 || fakefall!=0) && get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP);
27019
1/2
✓ Branch 0 taken 10745 times.
✗ Branch 1 not taken.
10745 if(isForceFaceUp) dir = up;
27020 10745 kill_enemy_sfx();
27021 10745 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27022 10745 screenscrolling = true;
27023 10745 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
27024
5/5
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3028 times.
✓ Branch 2 taken 2174 times.
✓ Branch 3 taken 2518 times.
✓ Branch 4 taken 3024 times.
10745 switch(scrolldir)
27025 {
27026 case up:
27027 3028 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27028 3028 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
27029 3028 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27030 3028 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27031 3028 break;
27032 case down:
27033 2174 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27034 2174 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
27035 2174 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27036 2174 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27037 2174 break;
27038 case left:
27039 2518 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
27040 2518 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27041 2518 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27042 2518 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27043 2518 break;
27044 case right:
27045 3024 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
27046 3024 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27047 3024 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27048 3024 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27049 3024 break;
27050 }
27051 10745 FFCore.init_combo_doscript();
27052 10745 tmpscr[1] = tmpscr[0];
27053
27054 10745 const int32_t _mapsSize = ZCMaps[currmap].tileWidth * ZCMaps[currmap].tileHeight;
27055
27056
2/2
✓ Branch 0 taken 64464 times.
✓ Branch 1 taken 10745 times.
75209 for(int32_t i = 0; i < 6; i++)
27057 {
27058 64464 tmpscr3[i] = tmpscr2[i];
27059 64464 }
27060
27061 10745 conveyclk = 2;
27062
27063 10745 mapscr *newscr = &tmpscr[0];
27064 10745 mapscr *oldscr = &tmpscr[1];
27065
27066 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
27067 10745 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
27068 10745 int32_t cx = 0;
27069 10745 int32_t step = get_scroll_step(scrolldir);
27070 10745 int32_t delay = get_scroll_delay(scrolldir);
27071 10745 bool end_frames = false;
27072
27073 10745 int32_t scx = get_bit(quest_rules,qr_FASTDNGN) ? 30 : 0;
27074
2/2
✓ Branch 0 taken 10109 times.
✓ Branch 1 taken 636 times.
10745 if(get_bit(quest_rules, qr_VERYFASTSCROLLING)) //just a minor adjustment.
27075 636 scx = 32; //for sideview very fast screolling.
27076
27077
27078 10745 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
27079 10745 actiontype lastaction = action;
27080 10745 ALLOFF(false, false);
27081 // for now, restore Hero's previous action
27082
2/2
✓ Branch 0 taken 10504 times.
✓ Branch 1 taken 241 times.
10745 if(!get_bit(quest_rules, qr_SCROLLING_KILLS_CHARGE))
27083 10745 attackclk = lastattackclk; spins = lastspins; charging = lastcharging; tapping = lasttapping;
27084 10745 action=lastaction; FFCore.setHeroAction(lastaction);
27085
27086 10745 lstep = (lstep + 6) % 12;
27087 10745 cx = scx;
27088 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
27089
4/4
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8649 times.
✓ Branch 3 taken 2095 times.
10745 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
27090 {
27091 2095 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
27092 2095 global_wait &= ~(1<<GLOBAL_SCRIPT_GAME);
27093 2095 }
27094 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
27095
5/6
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 194 times.
✓ Branch 3 taken 10550 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 194 times.
10745 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27096 {
27097 194 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
27098 194 player_waitdraw = false;
27099 194 }
27100 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
27101
5/6
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 10742 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
10745 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27102 {
27103 2 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
27104 2 dmap_waitdraw = false;
27105 2 }
27106 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
27107
3/6
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10745 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27108 {
27109 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
27110 passive_subscreen_waitdraw = false;
27111 }
27112 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
27113
3/8
✓ Branch 0 taken 10744 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10745 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27114 {
27115 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
27116 tmpscr->screen_waitdraw = 0;
27117 }
27118 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
27119
27120 10745 word c = tmpscr->numFFC();
27121
2/2
✓ Branch 0 taken 337747 times.
✓ Branch 1 taken 10745 times.
348492 for ( word q = 0; q < c; ++q )
27122 {
27123 //Z_scripterrlog("tmpscr->ffcswaitdraw is: %d\n", tmpscr->ffcswaitdraw);
27124
1/2
✓ Branch 0 taken 337747 times.
✗ Branch 1 not taken.
337747 if ( tmpscr->ffcswaitdraw&(1<<q) )
27125 {
27126 //Z_scripterrlog("FFC (%d) called Waitdraw()\n", q);
27127 if(tmpscr->ffcs[q].script != 0)
27128 {
27129 ZScriptVersion::RunScript(SCRIPT_FFC, tmpscr->ffcs[q].script, q);
27130 tmpscr->ffcswaitdraw &= ~(1<<q);
27131 }
27132 }
27133 337747 }
27134 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
27135 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
27136 //Waitdraw for item scripts.
27137 10745 FFCore.itemScriptEngineOnWaitdraw();
27138 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
27139 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
27140
27141 //Sprite scripts on Waitdraw
27142 10745 FFCore.eweaponScriptEngineOnWaitdraw();
27143 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
27144 10745 FFCore.itemSpriteScriptEngineOnWaitdraw();
27145 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
27146
27147 //This is no longer a do-while, as the first iteration is now slightly different. -Em
27148 10745 draw_screen(tmpscr,true,true);
27149
27150
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10744 times.
10745 if(cx == scx)
27151 10744 rehydratelake(false);
27152
27153 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27154 10745 advanceframe(true);
27155
27156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10745 times.
10745 if(Quit)
27157 {
27158 screenscrolling = false;
27159 return;
27160 }
27161
27162 10745 ++cx;
27163
2/2
✓ Branch 0 taken 109438 times.
✓ Branch 1 taken 10745 times.
120183 while(cx < 32)
27164 {
27165
1/2
✓ Branch 0 taken 109438 times.
✗ Branch 1 not taken.
109438 if(isForceFaceUp) dir = up;
27166
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 109398 times.
109438 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
27167 {
27168 40 script_drawing_commands.Clear();
27169 40 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27170 40 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
27171 40 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
27172 40 }
27173 109398 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27174 109438 draw_screen(tmpscr,true,true);
27175
27176
1/2
✓ Branch 0 taken 109438 times.
✗ Branch 1 not taken.
109438 if(cx == scx)
27177 rehydratelake(false);
27178
27179 109438 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27180 109438 advanceframe(true);
27181
27182
1/2
✓ Branch 0 taken 109438 times.
✗ Branch 1 not taken.
109438 if(Quit)
27183 {
27184 screenscrolling = false;
27185 return;
27186 }
27187
27188 109438 ++cx;
27189 }
27190 10745 script_drawing_commands.Clear();
27191 10745 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27192
27193
27194 //clear Hero's last hits
27195 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
27196
27197
4/4
✓ Branch 0 taken 5328 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 4420 times.
10745 switch(DMaps[currdmap].type&dmfTYPE)
27198 {
27199 case dmDNGN:
27200
1/2
✓ Branch 0 taken 4420 times.
✗ Branch 1 not taken.
4420 if(!get_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING))
27201 {
27202 markBmap(scrolldir);
27203 }
27204 4420 break;
27205 case dmOVERW: case dmBSOVERW:
27206
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 5240 times.
5328 if(get_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING))
27207 5240 break;
27208 [[fallthrough]];
27209 case dmCAVE:
27210 1084 markBmap(scrolldir);
27211 1084 break;
27212 }
27213
27214
1/2
✓ Branch 0 taken 10745 times.
✗ Branch 1 not taken.
10745 if(fixed_door)
27215 {
27216 unsetmapflag(mSECRET);
27217 fixed_door = false;
27218 }
27219 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
27220 10745 scrolling_scr = currscr;
27221
27222
5/5
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3028 times.
✓ Branch 2 taken 2174 times.
✓ Branch 3 taken 2518 times.
✓ Branch 4 taken 3024 times.
10745 switch(scrolldir)
27223 {
27224 case up:
27225 {
27226
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 2982 times.
3028 if(destscr != -1)
27227 46 currscr = destscr;
27228
3/4
✓ Branch 0 taken 2937 times.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2937 times.
2982 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27229 2937 currscr -= 16;
27230
27231 3028 loadscr(0,destdmap,currscr,scrolldir,overlay);
27232 3028 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
27233 3028 putscr(scrollbuf,0,0,newscr);
27234 3028 putscrdoors(scrollbuf,0,0,newscr);
27235 3028 sy=176;
27236
27237
2/2
✓ Branch 0 taken 2701 times.
✓ Branch 1 taken 327 times.
3028 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
27238 327 sy+=3;
27239
27240 3028 cx=176/step;
27241 3028 FFCore.init_combo_doscript();
27242 }
27243 3028 break;
27244
27245 case down:
27246 {
27247
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 2120 times.
2174 if(destscr != -1)
27248 54 currscr = destscr;
27249
3/4
✓ Branch 0 taken 2102 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2102 times.
2120 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27250 2102 currscr += 16;
27251
27252 2174 loadscr(0,destdmap,currscr,scrolldir,overlay);
27253 2174 putscr(scrollbuf,0,176,newscr);
27254 2174 putscrdoors(scrollbuf,0,176,newscr);
27255 2174 sy = 0;
27256
27257
2/2
✓ Branch 0 taken 2019 times.
✓ Branch 1 taken 155 times.
2174 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
27258 155 sy+=3;
27259
27260 2174 cx = 176 / step;
27261 2174 FFCore.init_combo_doscript();
27262 }
27263 2174 break;
27264
27265 case left:
27266 {
27267
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 2451 times.
2518 if(destscr!=-1)
27268 67 currscr = destscr;
27269
3/4
✓ Branch 0 taken 2433 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2433 times.
2451 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27270 2433 --currscr;
27271
27272 2518 loadscr(0,destdmap,currscr,scrolldir,overlay);
27273 2518 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
27274 2518 putscr(scrollbuf,0,0,newscr);
27275 2518 putscrdoors(scrollbuf,0,0,newscr);
27276 2518 sx = 256;
27277 2518 cx = 256 / step;
27278 2518 FFCore.init_combo_doscript();
27279 }
27280 2518 break;
27281
27282 case right:
27283 {
27284
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 2876 times.
3024 if(destscr != -1)
27285 148 currscr = destscr;
27286
3/4
✓ Branch 0 taken 2849 times.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2849 times.
2876 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27287 2849 ++currscr;
27288
27289 3024 loadscr(0,destdmap,currscr,scrolldir,overlay);
27290 3024 putscr(scrollbuf,256,0,newscr);
27291 3024 putscrdoors(scrollbuf,256,0,tmpscr);
27292 3024 sx = 0;
27293 3024 cx = 256 / step;
27294 3024 FFCore.init_combo_doscript();
27295 }
27296 3024 break;
27297 }
27298
27299 // change Hero's state if entering water
27300 10745 int32_t ahead = lookahead(scrolldir);
27301 10745 int32_t aheadflag = lookaheadflag(scrolldir);
27302 10745 int32_t lookaheadx = vbound(x+8,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
27303 10745 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0,160);
27304 10745 int32_t wateraheadx1 = vbound(x+4,0,240);
27305 10745 int32_t wateraheadx2 = vbound(x+11,0,240);;
27306 10745 int32_t wateraheady1 = vbound(y+9,0,160);
27307 10745 int32_t wateraheady2 = vbound(y+15,0,160);
27308 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27309 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27310 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
27311
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 2174 times.
✓ Branch 3 taken 2518 times.
✓ Branch 4 taken 3024 times.
10745 switch(scrolldir)
27312 {
27313 case up:
27314 3027 lookaheady=160;
27315 3027 wateraheady1=160;
27316 3027 wateraheady2=160;
27317 3027 break;
27318
27319 case down:
27320 2174 lookaheady=0;
27321 2174 wateraheady1=0;
27322 2174 wateraheady2=0;
27323 2174 break;
27324
27325 case left:
27326 2518 lookaheadx=240;
27327 2518 wateraheadx1=240;
27328 2518 wateraheadx2=240;
27329 2518 break;
27330
27331 case right:
27332 3024 lookaheadx=0;
27333 3024 wateraheadx1=0;
27334 3024 wateraheadx2=0;
27335 3024 break;
27336 }
27337
27338 10743 bool nowinwater = false;
27339
27340
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 10677 times.
10743 if(lastaction != inwind)
27341 {
27342
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 10481 times.
10677 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
27343 {
27344
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 189 times.
196 if (lookaheadraftflag(scrolldir))
27345 {
27346 189 action=rafting; FFCore.setHeroAction(rafting);
27347 189 raftclk=0;
27348 189 }
27349 196 }
27350
5/6
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 10304 times.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 156 times.
10481 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
27351 {
27352
9/16
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10 times.
✗ Branch 15 not taken.
156 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
27353 {
27354 146 SetSwim();
27355 146 hopclk = 0xFF;
27356 146 nowinwater = true;
27357 146 }
27358 else
27359 {
27360 10 action=hopping; FFCore.setHeroAction(hopping);
27361 10 hopclk = 2;
27362 10 nowinwater = true;
27363 }
27364 156 }
27365
3/4
✓ Branch 0 taken 10312 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10325 times.
10325 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
27366 {
27367 action = lastaction; FFCore.setHeroAction(lastaction);
27368 }
27369 else
27370 {
27371 10325 action=none; FFCore.setHeroAction(none);
27372 }
27373 10677 }
27374
27375
1/2
✓ Branch 0 taken 10743 times.
✗ Branch 1 not taken.
10743 isForceFaceUp = isForceFaceUp && canSideviewLadderRemote(lookaheadx,lookaheady);
27376
27377 // The naturaldark state can be read/set by an FFC script before
27378 // fade() or lighting() is called.
27379 10743 naturaldark = ((TheMaps[currmap*MAPSCRS+currscr].flags & fDARK) != 0);
27380
27381
2/2
✓ Branch 0 taken 10511 times.
✓ Branch 1 taken 232 times.
10743 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
27382
27383
2/2
✓ Branch 0 taken 10500 times.
✓ Branch 1 taken 243 times.
10743 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
27384 //Preloaded ffc scripts
27385 10743 homescr=currscr;
27386 10743 auto olddmap = currdmap;
27387
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 10428 times.
10743 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
27388
27389 10743 currdmap = newdmap;
27390 10743 ffscript_engine(true);
27391 10743 currdmap = olddmap;
27392
27393 // There are two occasions when scrolling must be darkened:
27394 // 1) When scrolling into a dark room.
27395 // 2) When scrolling between DMaps of different colours.
27396
4/4
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 10428 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 125 times.
10743 if(destdmap != -1 && DMaps[destdmap].color != currcset)
27397 {
27398
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
27399 125 darkroom = true;
27400 125 }
27401
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 10441 times.
10618 else if(!darkroom)
27402 10441 lighting(false, false); // NES behaviour: fade to dark before scrolling
27403
27404
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 10547 times.
10743 if(action != rafting) // Is this supposed to be here?!
27405
27406 10547 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
27407
27408 10743 cx *= delay; //so we can have drawing re-done every frame,
27409 //previously it was for(0 to delay) advanceframes at end of loop
27410 10743 int32_t no_move = 0;
27411
27412 10743 currdmap = newdmap;
27413
4/4
✓ Branch 0 taken 10743 times.
✓ Branch 1 taken 698721 times.
✓ Branch 2 taken 698721 times.
✓ Branch 3 taken 10743 times.
709464 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
27414 {
27415
3/4
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 577272 times.
✓ Branch 3 taken 121449 times.
698721 if (replay_is_active() && replay_get_version() < 3)
27416 {
27417 121449 replay_poll();
27418 121449 }
27419
1/2
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
698721 if(Quit)
27420 {
27421 screenscrolling = false;
27422 return;
27423 }
27424
27425
27426 698721 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
27427
27428
2/2
✓ Branch 0 taken 644854 times.
✓ Branch 1 taken 53867 times.
698721 if(no_move > 0)
27429 53867 no_move--;
27430
27431 //Don't want to move things on the first or last iteration, or between delays
27432
6/6
✓ Branch 0 taken 687978 times.
✓ Branch 1 taken 10743 times.
✓ Branch 2 taken 672516 times.
✓ Branch 3 taken 15462 times.
✓ Branch 4 taken 23129 times.
✓ Branch 5 taken 649387 times.
698721 if(i == 0 || cx == 0 || cx % delay != 0)
27433 49334 no_move++;
27434
27435
4/4
✓ Branch 0 taken 524511 times.
✓ Branch 1 taken 174210 times.
✓ Branch 2 taken 118651 times.
✓ Branch 3 taken 405860 times.
698721 if(scrolldir == up || scrolldir == down)
27436 {
27437
2/2
✓ Branch 0 taken 257684 times.
✓ Branch 1 taken 35177 times.
292861 if(!get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING))
27438 {
27439 //Add a few extra frames if on the second loop and cool scrolling is not set
27440
2/2
✓ Branch 0 taken 34695 times.
✓ Branch 1 taken 482 times.
35177 if(i == 1)
27441 {
27442 482 cx += (scrolldir == down) ? 3 : 2;
27443 482 no_move += (scrolldir == down) ? 3 : 2;
27444 482 }
27445 35177 }
27446 else
27447 {
27448 //4 frames after we've finished scrolling of being still
27449
4/4
✓ Branch 0 taken 9438 times.
✓ Branch 1 taken 248246 times.
✓ Branch 2 taken 4719 times.
✓ Branch 3 taken 4719 times.
257684 if(cx == 0 && !end_frames)
27450 {
27451 4719 cx += 4;
27452 4719 no_move += 4;
27453 4719 end_frames = true;
27454 4719 }
27455 }
27456 292861 }
27457
27458 //Move Hero and the scroll position
27459
2/2
✓ Branch 0 taken 64610 times.
✓ Branch 1 taken 634111 times.
698721 if(!no_move)
27460 {
27461
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 140576 times.
✓ Branch 2 taken 98759 times.
✓ Branch 3 taken 178737 times.
✓ Branch 4 taken 216039 times.
634111 switch(scrolldir)
27462 {
27463 case up:
27464 140576 sy -= step;
27465 140576 y += step;
27466 140576 break;
27467
27468 case down:
27469 98759 sy += step;
27470 98759 y -= step;
27471 98759 break;
27472
27473 case left:
27474 178737 sx -= step;
27475 178737 x += step;
27476 178737 break;
27477
27478 case right:
27479 216039 sx += step;
27480 216039 x -= step;
27481 216039 break;
27482 }
27483
27484 //bound Hero when me move him off the screen in the last couple of frames of scrolling
27485
2/2
✓ Branch 0 taken 12436 times.
✓ Branch 1 taken 621675 times.
634111 if(y > 160) y = 160;
27486
27487
2/2
✓ Branch 0 taken 8659 times.
✓ Branch 1 taken 625452 times.
634111 if(y < 0) y = 0;
27488
27489
2/2
✓ Branch 0 taken 11127 times.
✓ Branch 1 taken 622984 times.
634111 if(x > 240) x = 240;
27490
27491
2/2
✓ Branch 0 taken 13449 times.
✓ Branch 1 taken 620662 times.
634111 if(x < 0) x = 0;
27492
27493
4/4
✓ Branch 0 taken 633865 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 633855 times.
634111 if(ladderx > 0 || laddery > 0)
27494 {
27495 // If the ladder moves on both axes, the player can
27496 // gradually shift it by going back and forth
27497
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
27498 laddery = y.getInt();
27499 else
27500 256 ladderx = x.getInt();
27501 256 }
27502 634111 }
27503
27504 //Drawing
27505 698721 tx = sx;
27506 698721 ty = sy;
27507 698721 tx2 = sx;
27508 698721 ty2 = sy;
27509
27510
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 222087 times.
✓ Branch 2 taken 118651 times.
✓ Branch 3 taken 183773 times.
✓ Branch 4 taken 174210 times.
698721 switch(scrolldir)
27511 {
27512 case right:
27513 222087 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
27514 222087 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27515 222087 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
27516 222087 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27517 222087 tx -= 256;
27518 222087 break;
27519
27520 case down:
27521 118651 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27522 118651 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
27523 118651 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27524 118651 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
27525 118651 ty -= 176;
27526 118651 break;
27527
27528 case left:
27529 183773 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
27530 183773 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27531 183773 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
27532 183773 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27533 183773 tx2 -= 256;
27534 183773 break;
27535
27536 case up:
27537 174210 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27538 174210 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
27539 174210 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27540 174210 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
27541 174210 ty2 -= 176;
27542 174210 break;
27543 }
27544
27545 //FFScript.OnWaitdraw()
27546 698721 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
27547
27548 698721 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
27549 698721 clear_bitmap(scrollbuf);
27550 698721 clear_bitmap(framebuf);
27551 698721 clear_a5_bmp(rti_infolayer.bitmap);
27552
27553 698721 combotile_add_x = 0;
27554 698721 combotile_add_y = playing_field_offset;
27555
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 174210 times.
✓ Branch 2 taken 118651 times.
✓ Branch 3 taken 183773 times.
✓ Branch 4 taken 222087 times.
698721 switch(scrolldir)
27556 {
27557 case up:
27558
1/2
✓ Branch 0 taken 174210 times.
✗ Branch 1 not taken.
174210 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
27559
27560
1/2
✓ Branch 0 taken 174210 times.
✗ Branch 1 not taken.
174210 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
27561
27562
2/2
✓ Branch 0 taken 174193 times.
✓ Branch 1 taken 17 times.
174210 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
27563
27564
2/2
✓ Branch 0 taken 174193 times.
✓ Branch 1 taken 17 times.
174210 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
27565
27566 // Draw both screens' background layer primitives together, after both layers' combos.
27567 // Not ideal, but probably good enough for all realistic purposes.
27568
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 174210 times.
✓ Branch 2 taken 174210 times.
✗ Branch 3 not taken.
174210 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27569
27570
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 174193 times.
✓ Branch 2 taken 174193 times.
✓ Branch 3 taken 17 times.
174210 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27571
27572 174210 combotile_add_y -= sy;
27573 174210 putscr(scrollbuf, 0, 0, newscr);
27574 174210 putscr(scrollbuf, 0, 176, oldscr);
27575 174210 break;
27576
27577 case down:
27578
1/2
✓ Branch 0 taken 118651 times.
✗ Branch 1 not taken.
118651 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
27579
27580
1/2
✓ Branch 0 taken 118651 times.
✗ Branch 1 not taken.
118651 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
27581
27582
1/2
✓ Branch 0 taken 118651 times.
✗ Branch 1 not taken.
118651 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
27583
27584
1/2
✓ Branch 0 taken 118651 times.
✗ Branch 1 not taken.
118651 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
27585
27586
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 118651 times.
✓ Branch 2 taken 118651 times.
✗ Branch 3 not taken.
118651 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27587
27588
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 118651 times.
✓ Branch 2 taken 118651 times.
✗ Branch 3 not taken.
118651 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27589
27590 118651 combotile_add_y -= sy;
27591 118651 putscr(scrollbuf, 0, 0, oldscr);
27592 118651 putscr(scrollbuf, 0, 176, newscr);
27593 118651 break;
27594
27595 case left:
27596
2/2
✓ Branch 0 taken 183707 times.
✓ Branch 1 taken 66 times.
183773 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
27597
27598
2/2
✓ Branch 0 taken 183707 times.
✓ Branch 1 taken 66 times.
183773 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
27599
27600
2/2
✓ Branch 0 taken 183755 times.
✓ Branch 1 taken 18 times.
183773 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
27601
27602
2/2
✓ Branch 0 taken 183755 times.
✓ Branch 1 taken 18 times.
183773 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
27603
27604
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 183707 times.
✓ Branch 2 taken 183641 times.
✓ Branch 3 taken 132 times.
183773 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27605
27606
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 183755 times.
✓ Branch 2 taken 183755 times.
✓ Branch 3 taken 18 times.
183773 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27607
27608 183773 combotile_add_x -= sx;
27609 183773 putscr(scrollbuf, 0, 0, newscr);
27610 183773 putscr(scrollbuf, 256, 0, oldscr);
27611 183773 break;
27612
27613 case right:
27614
2/2
✓ Branch 0 taken 221955 times.
✓ Branch 1 taken 132 times.
222087 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
27615
27616
1/2
✓ Branch 0 taken 222087 times.
✗ Branch 1 not taken.
222087 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
27617
27618
1/2
✓ Branch 0 taken 222087 times.
✗ Branch 1 not taken.
222087 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
27619
27620
1/2
✓ Branch 0 taken 222087 times.
✗ Branch 1 not taken.
222087 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
27621
27622
4/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 221955 times.
✓ Branch 2 taken 221955 times.
✓ Branch 3 taken 132 times.
222087 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27623
27624
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 222087 times.
✓ Branch 2 taken 222087 times.
✗ Branch 3 not taken.
222087 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27625
27626 222087 combotile_add_x -= sx;
27627 222087 putscr(scrollbuf, 0, 0, oldscr);
27628 222087 putscr(scrollbuf, 256, 0, newscr);
27629 222087 break;
27630 }
27631
27632 698721 combotile_add_x = 0;
27633 698721 combotile_add_y = 0;
27634
27635 698721 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
27636 698721 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
27637
27638 698721 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
27639 698721 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
27640
27641
2/2
✓ Branch 0 taken 648289 times.
✓ Branch 1 taken 50432 times.
698721 if(get_bit(quest_rules, qr_FFCSCROLL))
27642 {
27643 50432 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
27644 50432 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
27645 50432 }
27646
27647
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 698655 times.
698721 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
27648
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 698523 times.
698721 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
27649
27650 //push blocks
27651 698721 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
27652 698721 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
27653
2/2
✓ Branch 0 taken 689963 times.
✓ Branch 1 taken 8758 times.
698721 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
27654 {
27655 8758 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
27656 8758 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
27657 8758 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
27658 8758 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
27659 8758 }
27660
27661 698721 do_walkflags(oldscr, tx2, ty2,3); //show walkflags if the cheat is on
27662 698721 do_walkflags(newscr, tx, ty,2);
27663
27664 698721 do_effectflags(oldscr, tx2, ty2,3); //show effectflags if the cheat is on
27665 698721 do_effectflags(newscr, tx, ty,2);
27666
27667
27668 698721 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
27669 698721 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
27670 698721 herostep();
27671
1/2
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
698721 if(isForceFaceUp) dir = up;
27672
27673
5/6
✓ Branch 0 taken 698671 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 698621 times.
✓ Branch 4 taken 698671 times.
✓ Branch 5 taken 698671 times.
698721 if((z > 0 || fakez > 0) && (!get_bit(quest_rules,qr_SHADOWSFLICKER) || frame&1))
27674 {
27675 1397292 drawshadow(framebuf, get_bit(quest_rules, qr_TRANSSHADOWS) != 0);
27676 1397292 }
27677
27678
4/4
✓ Branch 0 taken 355399 times.
✓ Branch 1 taken 343322 times.
✓ Branch 2 taken 126247 times.
✓ Branch 3 taken 229152 times.
698721 if(!isdungeon() || get_bit(quest_rules,qr_FREEFORM))
27679 {
27680 469569 draw_under(framebuf); //draw the ladder or raft
27681 469569 decorations.draw2(framebuf, true);
27682 469569 draw(framebuf); //Hero
27683 469569 decorations.draw(framebuf, true);
27684 469569 }
27685
27686
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 698686 times.
698721 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
27687
27688 698721 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
27689 698721 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
27690
2/2
✓ Branch 0 taken 692850 times.
✓ Branch 1 taken 5871 times.
698721 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
27691 {
27692 5871 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
27693 5871 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
27694 5871 }
27695 698721 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
27696 698721 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
27697 698721 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
27698
27699
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 698686 times.
698721 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
27700
27701 698721 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
27702 698721 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
27703
2/2
✓ Branch 0 taken 692850 times.
✓ Branch 1 taken 5871 times.
698721 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
27704 {
27705 5871 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
27706 5871 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
27707 5871 }
27708 698721 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
27709 698721 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
27710 698721 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
27711
27712
27713
1/2
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
698721 if(msg_bg_display_buf->clip == 0)
27714 {
27715 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27716 }
27717
1/2
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
698721 if(msg_portrait_display_buf->clip == 0)
27718 {
27719 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27720 }
27721
1/2
✓ Branch 0 taken 698721 times.
✗ Branch 1 not taken.
698721 if(msg_txt_display_buf->clip == 0)
27722 {
27723 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27724 }
27725
27726
6/6
✓ Branch 0 taken 12165 times.
✓ Branch 1 taken 686556 times.
✓ Branch 2 taken 11939 times.
✓ Branch 3 taken 226 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 11856 times.
698721 if(get_bit(quest_rules, qr_NEW_DARKROOM) && ((newscr->flags&fDARK)||(oldscr->flags&fDARK)))
27727 {
27728 309 clear_to_color(darkscr_bmp_curscr, game->get_darkscr_color());
27729 309 clear_to_color(darkscr_bmp_curscr_trans, game->get_darkscr_color());
27730 309 clear_to_color(darkscr_bmp_scrollscr, game->get_darkscr_color());
27731 309 clear_to_color(darkscr_bmp_scrollscr_trans, game->get_darkscr_color());
27732 309 calc_darkroom_combos(true);
27733 309 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
27734 309 }
27735
27736
4/4
✓ Branch 0 taken 12165 times.
✓ Branch 1 taken 686556 times.
✓ Branch 2 taken 8646 times.
✓ Branch 3 taken 3519 times.
698721 if(get_bit(quest_rules, qr_NEW_DARKROOM) && get_bit(quest_rules, qr_NEWDARK_L6))
27737 {
27738 3519 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
27739 3519 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
27740 3519 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
27741
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(newscr->flags & fDARK)
27742 {
27743 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27744 {
27745 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
27746 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27747 }
27748
27749 color_map = &trans_table2;
27750 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27751 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
27752 else
27753 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
27754 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
27755 color_map = &trans_table;
27756 }
27757
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(oldscr->flags & fDARK)
27758 {
27759 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27760 {
27761 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
27762 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27763 }
27764
27765 color_map = &trans_table2;
27766 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27767 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
27768 else
27769 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
27770 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
27771 color_map = &trans_table;
27772 }
27773 3519 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
27774 3519 }
27775 698721 put_passive_subscr(framebuf, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
27776
2/2
✓ Branch 0 taken 520438 times.
✓ Branch 1 taken 178283 times.
698721 if(get_bit(quest_rules,qr_SUBSCREENOVERSPRITES))
27777 178283 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
27778
27779
4/4
✓ Branch 0 taken 12165 times.
✓ Branch 1 taken 686556 times.
✓ Branch 2 taken 8646 times.
✓ Branch 3 taken 3519 times.
698721 if(get_bit(quest_rules, qr_NEW_DARKROOM) && !get_bit(quest_rules, qr_NEWDARK_L6))
27780 {
27781 8646 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
27782 8646 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
27783 8646 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
27784
2/2
✓ Branch 0 taken 8420 times.
✓ Branch 1 taken 226 times.
8646 if(newscr->flags & fDARK)
27785 {
27786
1/2
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
226 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27787 {
27788 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
27789 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27790 }
27791
27792 226 color_map = &trans_table2;
27793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27794 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
27795 else
27796 226 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
27797 226 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
27798 226 color_map = &trans_table;
27799 226 }
27800
2/2
✓ Branch 0 taken 8437 times.
✓ Branch 1 taken 209 times.
8646 if(oldscr->flags & fDARK)
27801 {
27802
1/2
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
209 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27803 {
27804 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
27805 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27806 }
27807
27808 209 color_map = &trans_table2;
27809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27810 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
27811 else
27812 209 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
27813 209 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
27814 209 color_map = &trans_table;
27815 209 }
27816 8646 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
27817 8646 }
27818 698721 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
27819
27820 //end drawing
27821 698721 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27822 698721 advanceframe(true/*,true,false*/);
27823
27824 //Don't clear the last frame, unless 'fixed'
27825
4/4
✓ Branch 0 taken 10743 times.
✓ Branch 1 taken 687978 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 10502 times.
698721 if(cx > 0 || get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
27826 688219 script_drawing_commands.Clear();
27827 698721 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27828 698721 actiontype lastaction = action;
27829 698721 action=scrolling; FFCore.setHeroAction(scrolling);
27830 698721 FFCore.runF6Engine();
27831 698721 action=lastaction; FFCore.setHeroAction(lastaction);
27832 698721 } //end main scrolling loop
27833 10743 currdmap = olddmap;
27834
27835 10743 clear_bitmap(msg_txt_display_buf);
27836 10743 set_clip_state(msg_txt_display_buf, 1);
27837 10743 clear_bitmap(msg_bg_display_buf);
27838 10743 set_clip_state(msg_bg_display_buf, 1);
27839 10743 clear_bitmap(msg_portrait_display_buf);
27840 10743 set_clip_state(msg_portrait_display_buf, 1);
27841
27842 //Move hero to the other side of the screen if scrolling's not turned on
27843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10743 times.
10743 if(get_bit(quest_rules, qr_NOSCROLL))
27844 {
27845 switch(scrolldir)
27846 {
27847 case up:
27848 y = 160;
27849 break;
27850
27851 case down:
27852 y = 0;
27853 break;
27854
27855 case left:
27856 x = 240;
27857 break;
27858
27859 case right:
27860 x = 0;
27861 break;
27862 }
27863 }
27864
27865
3/4
✓ Branch 0 taken 10742 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 10743 times.
✗ Branch 3 not taken.
10743 if((z > 0 || fakez > 0) && isSideViewHero())
27866 {
27867 y -= z;
27868 y -= fakez;
27869 z = 0;
27870 fakez = 0;
27871 }
27872
27873 10743 combotile_add_x = 0;
27874 10743 combotile_add_y = 0;
27875
27876 10743 set_respawn_point(false);
27877 10743 trySideviewLadder();
27878 10743 warpx = -1;
27879 10743 warpy = -1;
27880
27881 10743 screenscrolling = false;
27882 10743 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
27883 10743 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27884 10743 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27885 10743 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27886 10743 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27887
27888
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 10428 times.
10743 if(destdmap != -1)
27889 {
27890 315 bool changedlevel = false;
27891 315 bool changeddmap = false;
27892
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 226 times.
315 if(olddmap != destdmap)
27893 {
27894 226 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
27895 226 changeddmap = true;
27896 226 }
27897
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 79 times.
315 if(DMaps[olddmap].level != DMaps[destdmap].level)
27898 {
27899 79 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
27900 79 changedlevel = true;
27901 79 }
27902 315 dlevel = DMaps[destdmap].level;
27903 315 currdmap = destdmap;
27904
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 226 times.
315 if(changeddmap)
27905 {
27906 226 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
27907 226 }
27908
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 79 times.
315 if(changedlevel)
27909 {
27910 79 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
27911 79 }
27912 315 }
27913
27914 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
27915 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
27916 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
27917 //direction. -DD
27918
27919
2/2
✓ Branch 0 taken 10587 times.
✓ Branch 1 taken 156 times.
10743 if(nowinwater)
27920 {
27921 156 SetSwim();
27922 156 hopclk = 0xFF;
27923 156 }
27924
27925 // NES behaviour: Fade to light after scrolling
27926 10743 lighting(false, false); // No, we don't need to set naturaldark...
27927
27928 10743 init_dmap();
27929 10743 putscr(scrollbuf,0,0,newscr);
27930 10743 putscrdoors(scrollbuf,0,0,newscr);
27931
27932 // Check for raft flags
27933
6/6
✓ Branch 0 taken 10547 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 10391 times.
✓ Branch 3 taken 156 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 10340 times.
10743 if(action!=rafting && hopclk==0 && !toogam)
27934 {
27935
3/4
✓ Branch 0 taken 10337 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10337 times.
10340 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
27936 {
27937 3 sfx(tmpscr->secretsfx);
27938 3 action=rafting; FFCore.setHeroAction(rafting);
27939 3 raftclk=0;
27940 3 }
27941
27942 // Half a tile off?
27943
6/8
✓ Branch 0 taken 7785 times.
✓ Branch 1 taken 2552 times.
✓ Branch 2 taken 3015 times.
✓ Branch 3 taken 4770 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5567 times.
✓ Branch 6 taken 10337 times.
✗ Branch 7 not taken.
15904 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
27944 {
27945 sfx(tmpscr->secretsfx);
27946 action=rafting; FFCore.setHeroAction(rafting);
27947 raftclk=0;
27948 }
27949 10340 }
27950
27951 10743 opendoors=0;
27952 10743 markBmap(-1);
27953
27954
2/2
✓ Branch 0 taken 6322 times.
✓ Branch 1 taken 4421 times.
10743 if(isdungeon())
27955 {
27956
3/3
✓ Branch 0 taken 2562 times.
✓ Branch 1 taken 1145 times.
✓ Branch 2 taken 714 times.
4421 switch(tmpscr->door[scrolldir^1])
27957 {
27958 case dOPEN:
27959 case dUNLOCKED:
27960 case dOPENBOSS:
27961 2562 dir = scrolldir;
27962
27963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2562 times.
2562 if(action!=rafting)
27964 2562 stepforward(diagonalMovement?11:12, false);
27965
27966 2562 break;
27967
27968 case dSHUTTER:
27969 case d1WAYSHUTTER:
27970 1145 dir = scrolldir;
27971
27972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1145 times.
1145 if(action!=rafting)
27973 1145 stepforward(diagonalMovement?21:24, false);
27974
27975 1145 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
27976 1145 opendoors=-4;
27977 1145 sfx(WAV_DOOR);
27978 1145 break;
27979
27980 default:
27981 714 dir = scrolldir;
27982
27983
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 667 times.
714 if(action!=rafting)
27984 667 stepforward(diagonalMovement?21:24, false);
27985 714 }
27986 4421 }
27987
27988
1/2
✓ Branch 0 taken 10743 times.
✗ Branch 1 not taken.
10743 if(isForceFaceUp) dir = up;
27989
27990
1/2
✓ Branch 0 taken 10743 times.
✗ Branch 1 not taken.
10743 if(action == scrolling)
27991 {
27992 action=none; FFCore.setHeroAction(none);
27993 }
27994
27995
2/4
✓ Branch 0 taken 10743 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10743 times.
10743 if(action != attacking && action != sideswimattacking)
27996 {
27997 10743 charging = 0;
27998 10743 tapping = false;
27999 10743 }
28000
28001 10743 map_bkgsfx(true);
28002
28003
2/2
✓ Branch 0 taken 10716 times.
✓ Branch 1 taken 27 times.
10743 if(newscr->flags2&fSECRET)
28004 {
28005 27 sfx(newscr->secretsfx);
28006 27 }
28007
28008 10743 playLevelMusic();
28009
28010 10743 newscr_clk = frame;
28011 10743 activated_timed_warp=false;
28012 10743 loadside = scrolldir^1;
28013 10743 FFCore.init_combo_doscript();
28014 10743 eventlog_mapflags();
28015 10743 decorations.animate(); //continue to animate tall grass during scrolling
28016
2/2
✓ Branch 0 taken 10502 times.
✓ Branch 1 taken 241 times.
10743 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
28017 {
28018
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 235 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
241 if(olddmap == newdmap || (replay_is_active() && replay_get_version() < 15))
28019 241 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
28020 else refresh_dmap_scrollscript = true;
28021 241 }
28022
1/2
✓ Branch 0 taken 10743 times.
✗ Branch 1 not taken.
10743 if(!get_bit(quest_rules,qr_SCROLLWARP_NO_RESET_FRAME))
28023 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
28024 10743 }
28025
28026
28027
28028 // How much to reduce Hero's damage, taking into account various rings.
28029 6827 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
28030 {
28031
1/2
✓ Branch 0 taken 6827 times.
✗ Branch 1 not taken.
6827 if(dmg < 0) return dmg; //Don't reduce healing
28032
2/2
✓ Branch 0 taken 6690 times.
✓ Branch 1 taken 137 times.
6827 if ( get_bit(quest_rules,qr_BROKEN_RING_POWER) )
28033 {
28034 6690 int32_t divisor = 1;
28035 6690 float percentage = 1;
28036 6690 int32_t itemid = current_item_id(itype_ring);
28037 6690 bool usering = false;
28038
28039
4/4
✓ Branch 0 taken 4845 times.
✓ Branch 1 taken 1845 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 4808 times.
6690 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
28040 {
28041 4808 usering = true;
28042 4808 paymagiccost(itemid);
28043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4808 times.
4808 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28044 {
28045 percentage *= itemsbuf[itemid].power/100.0;
28046 }
28047 else
28048 {
28049 4808 divisor *= itemsbuf[itemid].power;
28050 }
28051 4808 }
28052
28053 /* Now for the Peril Ring */
28054 6690 itemid = current_item_id(itype_perilring);
28055
28056
7/10
✓ Branch 0 taken 502 times.
✓ Branch 1 taken 6188 times.
✓ Branch 2 taken 502 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 427 times.
✓ Branch 6 taken 75 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 75 times.
6690 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
28057 {
28058 75 usering = true;
28059 75 paymagiccost(itemid);
28060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28061 {
28062 percentage *= itemsbuf[itemid].power/100.0;
28063 }
28064 else
28065 {
28066 75 divisor *= itemsbuf[itemid].power;
28067 }
28068 75 }
28069
28070 // Ring divisor of 0 = no damage. -L
28071
4/6
✓ Branch 0 taken 4815 times.
✓ Branch 1 taken 1875 times.
✓ Branch 2 taken 4815 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4815 times.
6690 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
28072 return 0;
28073
28074
1/2
✓ Branch 0 taken 6690 times.
✗ Branch 1 not taken.
6690 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
28075
28076
1/2
✓ Branch 0 taken 6690 times.
✗ Branch 1 not taken.
6690 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
28077
1/2
✓ Branch 0 taken 6690 times.
✗ Branch 1 not taken.
6690 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
28078
28079 }
28080 else
28081 {
28082 137 double divisor = 1;
28083 137 double percentage = 1;
28084 137 int32_t itemid = current_item_id(itype_ring);
28085 137 bool usering = false;
28086
28087
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 134 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
137 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
28088 {
28089 3 usering = true;
28090 3 paymagiccost(itemid);
28091
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28092 {
28093 1 double perc = itemsbuf[itemid].power/100.0;
28094
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
28095 1 percentage *= perc;
28096 1 }
28097 else
28098 {
28099
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].power < 0)
28100 divisor /= -(itemsbuf[itemid].power);
28101 2 else divisor *= itemsbuf[itemid].power;
28102 }
28103 3 }
28104
28105 /* Now for the Peril Ring */
28106 137 itemid = current_item_id(itype_perilring);
28107
28108
4/10
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 135 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
137 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
28109 {
28110 usering = true;
28111 paymagiccost(itemid);
28112 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28113 {
28114 double perc = itemsbuf[itemid].power/100.0;
28115 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
28116 percentage *= perc;
28117 }
28118 else
28119 {
28120 if(itemsbuf[itemid].power < 0)
28121 divisor /= -(itemsbuf[itemid].power);
28122 else divisor *= itemsbuf[itemid].power;
28123 }
28124 }
28125
28126 // Ring divisor of 0 = no damage. -L
28127
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 134 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
137 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
28128 return 0;
28129
28130 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
28131
1/2
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
137 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
28132 }
28133 6827 }
28134
28135 // Should swinging the hammer make the 'pound' sound?
28136 // Or is Hero just hitting air?
28137 2216 bool HeroClass::sideviewhammerpound()
28138 {
28139 2216 int32_t wx=0,wy=0;
28140
28141
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 638 times.
✓ Branch 4 taken 740 times.
2216 switch(dir)
28142 {
28143 case up:
28144 350 wx=-1;
28145 350 wy=-15;
28146
28147
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(isSideViewHero()) wy+=8;
28148
28149 350 break;
28150
28151 case down:
28152 488 wx=8;
28153 488 wy=28;
28154
28155
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(isSideViewHero()) wy-=8;
28156
28157 488 break;
28158
28159 case left:
28160 638 wx=-8;
28161 638 wy=14;
28162
28163
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 6 times.
638 if(isSideViewHero()) wy+=8;
28164
28165 638 break;
28166
28167 case right:
28168 740 wx=21;
28169 740 wy=14;
28170
28171
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(isSideViewHero()) wy+=8;
28172
28173 740 break;
28174 }
28175
28176
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2210 times.
2216 if(!isSideViewHero())
28177 {
28178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2210 times.
2210 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
28179 }
28180
28181
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
28182
28183 if(dir==left || dir==right)
28184 {
28185 wx+=16;
28186
28187 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
28188 }
28189
28190 return false;
28191 2216 }
28192
28193 /************************************/
28194 /******** More Items Code *********/
28195 /************************************/
28196
28197 // The following are only used for Hero damage. Damage is in quarter hearts.
28198 3789 int32_t enemy_dp(int32_t index)
28199 {
28200 3789 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
28201 }
28202
28203 2890 int32_t ewpn_dp(int32_t index)
28204 {
28205 2890 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
28206 }
28207
28208 27 int32_t lwpn_dp(int32_t index)
28209 {
28210 27 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
28211 }
28212
28213 93446969 bool checkbunny(int32_t itemid)
28214 {
28215
3/4
✓ Branch 0 taken 93342303 times.
✓ Branch 1 taken 104666 times.
✓ Branch 2 taken 104666 times.
✗ Branch 3 not taken.
93446969 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
28216 }
28217
28218 22509413 bool usesSwordJinx(int32_t itemid)
28219 {
28220 22509413 itemdata const& it = itemsbuf[itemid];
28221 22509413 bool ret = (it.family==itype_sword);
28222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22509413 times.
22509413 if(it.flags & ITEM_FLIP_JINX) return !ret;
28223 22509413 return ret;
28224 22509413 }
28225 20122827 bool checkitem_jinx(int32_t itemid)
28226 {
28227 20122827 itemdata const& it = itemsbuf[itemid];
28228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20122827 times.
20122827 if(it.flags & ITEM_JINX_IMMUNE) return true;
28229
2/2
✓ Branch 0 taken 5407818 times.
✓ Branch 1 taken 14715009 times.
20122827 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
28230 14715009 return HeroItemClk() == 0;
28231 20122827 }
28232
28233 373051 int32_t Bweapon(int32_t pos)
28234 {
28235
4/4
✓ Branch 0 taken 373049 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 741 times.
✓ Branch 3 taken 372308 times.
373051 if(pos < 0 || current_subscreen_active == NULL)
28236 {
28237 743 return 0;
28238 }
28239
28240 372308 int32_t p=-1;
28241
28242
4/4
✓ Branch 0 taken 104085 times.
✓ Branch 1 taken 10828479 times.
✓ Branch 2 taken 104085 times.
✓ Branch 3 taken 10828479 times.
10932564 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL && i < MAXSUBSCREENITEMS; ++i)
28243 {
28244
4/4
✓ Branch 0 taken 7818793 times.
✓ Branch 1 taken 3009686 times.
✓ Branch 2 taken 7550570 times.
✓ Branch 3 taken 268223 times.
10828479 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM && current_subscreen_active->objects[i].d3==pos)
28245 {
28246 268223 p=i;
28247 268223 break;
28248 }
28249 10560256 }
28250
28251
2/2
✓ Branch 0 taken 268223 times.
✓ Branch 1 taken 104085 times.
372308 if(p==-1)
28252 {
28253 104085 return 0;
28254 }
28255
28256 268223 int32_t actualItem = current_subscreen_active->objects[p].d8;
28257 //int32_t familyCheck = actualItem ? itemsbuf[actualItem].family : current_subscreen_active->objects[p].d1
28258 268223 int32_t family = -1;
28259 268223 bool bow = false;
28260
28261
2/2
✓ Branch 0 taken 9486 times.
✓ Branch 1 taken 258737 times.
268223 if(actualItem)
28262 {
28263 9486 bool select = false;
28264
28265
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6222 times.
9486 switch(itemsbuf[actualItem-1].family)
28266 {
28267 case itype_bomb:
28268 if((game->get_bombs() ||
28269 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28270 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitBomb))) ||
28271 current_item_power(itype_bombbag))
28272 {
28273 select=true;
28274 }
28275
28276 break;
28277
28278 case itype_bowandarrow:
28279 case itype_arrow:
28280 if(actualItem-1>-1 && current_item_id(itype_bow)>-1)
28281 {
28282 //bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
28283 select=true;
28284 }
28285
28286 break;
28287
28288 case itype_letterpotion:
28289 /*if(current_item_id(itype_potion)>-1)
28290 {
28291 select=true;
28292 }
28293 else if(current_item_id(itype_letter)>-1)
28294 {
28295 select=true;
28296 }*/
28297 break;
28298
28299 case itype_sbomb:
28300 {
28301 int32_t bombbagid = current_item_id(itype_bombbag);
28302
28303 if((game->get_sbombs() ||
28304 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28305 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitSBomb))) ||
28306 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
28307 {
28308 select=true;
28309 }
28310
28311 break;
28312 }
28313
28314 case itype_sword:
28315 {
28316
1/2
✓ Branch 0 taken 6222 times.
✗ Branch 1 not taken.
6222 if(!get_bit(quest_rules,qr_SELECTAWPN))
28317 break;
28318
28319 6222 select=true;
28320 }
28321 6222 break;
28322
28323 default:
28324 3264 select=true;
28325 3264 }
28326
28327
4/6
✓ Branch 0 taken 9486 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7619 times.
✓ Branch 3 taken 1867 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7619 times.
9486 if(!item_disabled(actualItem-1) && game->get_item(actualItem-1) && select)
28328 {
28329 7619 directItem = actualItem-1;
28330
28331
2/4
✓ Branch 0 taken 7619 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7619 times.
✗ Branch 3 not taken.
7619 if(directItem>-1 && itemsbuf[directItem].family == itype_arrow) bow=true;
28332
28333 7619 return actualItem-1+(bow?0xF000:0);
28334 }
28335 1867 else return 0;
28336 }
28337
28338 258737 directItem = -1;
28339
28340
6/6
✓ Branch 0 taken 25981 times.
✓ Branch 1 taken 3167 times.
✓ Branch 2 taken 213527 times.
✓ Branch 3 taken 10562 times.
✓ Branch 4 taken 4033 times.
✓ Branch 5 taken 1467 times.
258737 switch(current_subscreen_active->objects[p].d1)
28341 {
28342 case itype_bomb:
28343 {
28344 25981 int32_t bombid = current_item_id(itype_bomb);
28345
28346
4/4
✓ Branch 0 taken 5583 times.
✓ Branch 1 taken 20398 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 5550 times.
31564 if((game->get_bombs() ||
28347 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28348
3/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 5495 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
5583 (bombid>-1 && itemsbuf[bombid].misc1==0 && Lwpns.idCount(wLitBomb)>0)) ||
28349 5583 current_item_power(itype_bombbag))
28350 {
28351 20431 family=itype_bomb;
28352 20431 }
28353
28354 25981 break;
28355 }
28356
28357 case itype_bowandarrow:
28358 case itype_arrow:
28359
4/4
✓ Branch 0 taken 8957 times.
✓ Branch 1 taken 1605 times.
✓ Branch 2 taken 8956 times.
✓ Branch 3 taken 1 times.
10562 if(current_item_id(itype_bow)>-1 && current_item_id(itype_arrow)>-1)
28360 {
28361 8956 bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
28362 8956 family=itype_arrow;
28363 8956 }
28364
28365 10562 break;
28366
28367 case itype_letterpotion:
28368
2/2
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 2030 times.
4033 if(current_item_id(itype_potion)>-1)
28369 {
28370 2003 family=itype_potion;
28371 2003 }
28372
2/2
✓ Branch 0 taken 1541 times.
✓ Branch 1 taken 489 times.
2030 else if(current_item_id(itype_letter)>-1)
28373 {
28374 489 family=itype_letter;
28375 489 }
28376
28377 4033 break;
28378
28379 case itype_sbomb:
28380 {
28381 3167 int32_t bombbagid = current_item_id(itype_bombbag);
28382 3167 int32_t sbombid = current_item_id(itype_sbomb);
28383
28384
3/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 1737 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
3177 if((game->get_sbombs() ||
28385 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28386
3/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 1361 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
1430 (sbombid>-1 && itemsbuf[sbombid].misc1==0 && Lwpns.idCount(wLitSBomb)>0)) ||
28387
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1420 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
1430 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
28388 {
28389 1747 family=itype_sbomb;
28390 1747 }
28391
28392 3167 break;
28393 }
28394
28395 case itype_sword:
28396 {
28397
2/2
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 30 times.
1467 if(!get_bit(quest_rules,qr_SELECTAWPN))
28398 30 break;
28399
28400 1437 family=itype_sword;
28401 }
28402 1437 break;
28403
28404 default:
28405 213527 family=current_subscreen_active->objects[p].d1;
28406 213527 }
28407
28408
2/2
✓ Branch 0 taken 248590 times.
✓ Branch 1 taken 10147 times.
258737 if(family==-1)
28409 10147 return 0;
28410
28411
2/2
✓ Branch 0 taken 12324088 times.
✓ Branch 1 taken 18931 times.
12343019 for(int32_t j=0; j<MAXITEMS; j++)
28412 {
28413 // Find the item that matches this subscreen object.
28414
5/6
✓ Branch 0 taken 422695 times.
✓ Branch 1 taken 11901393 times.
✓ Branch 2 taken 229659 times.
✓ Branch 3 taken 193036 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 229659 times.
12324088 if(itemsbuf[j].family==family && j == current_item_id(family,false) && !item_disabled(j))
28415 {
28416 229659 return j+(bow?0xF000:0);
28417 }
28418 12094429 }
28419
28420 18931 return 0;
28421 373051 }
28422
28423 93 int32_t BWeapon_to_Pos(int32_t bweapon)
28424 {
28425
2/2
✓ Branch 0 taken 5272 times.
✓ Branch 1 taken 19 times.
5291 for (int32_t i = 0; i < MAXSUBSCREENITEMS; ++i)
28426 {
28427
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 5198 times.
5272 if (Bweapon(i) == bweapon)
28428 {
28429 74 return i;
28430 }
28431 5198 }
28432 19 return -1;
28433 93 }
28434
28435 2 void stopCaneOfByrna()
28436 {
28437
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
42 for(int32_t i=0; i<Lwpns.Count(); i++)
28438 {
28439 40 weapon *w = ((weapon*)Lwpns.spr(i));
28440
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2 times.
40 if(w->id==wCByrna)
28441 2 w->dead=1;
28442 40 }
28443 2 }
28444
28445 /* Crashes if used by ffscript.cpp, in case LINKITEMD
28446 void stopCaneOfByrna()
28447 {
28448 byte prnt_cane = -1;
28449 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
28450 prnt_cane = ew->parentitem;
28451 for(int32_t i=0; i<Lwpns.Count(); i++)
28452 {
28453 weapon *w = ((weapon*)Lwpns.spr(i));
28454
28455 if(w->id==wCByrna)
28456 {
28457 w->dead=1;
28458 }
28459 }
28460 if ( prnt_cane > -1 )
28461 {
28462 stop_sfx(itemsbuf[prnt_cane].usesound);
28463 }
28464 }
28465 */
28466 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
28467 6416929 void HeroClass::cleanupByrna()
28468 {
28469
2/2
✓ Branch 0 taken 6416852 times.
✓ Branch 1 taken 77 times.
6416929 if ( last_cane_of_byrna_item_id > -1 )
28470 {
28471 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
28472
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 75 times.
77 if ( !(Lwpns.idCount(wCByrna)) )
28473 {
28474 2 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
28475 2 last_cane_of_byrna_item_id = -1;
28476 2 }
28477 77 }
28478 6416929 }
28479
28480 // Used to find out if an item family is attached to one of the buttons currently pressed.
28481 2071348 bool isWpnPressed(int32_t itype)
28482 {
28483 //0xFFF for subscreen overrides
28484 //Will crash on win10 without it! -Z
28485
4/4
✓ Branch 0 taken 403821 times.
✓ Branch 1 taken 1667527 times.
✓ Branch 2 taken 368537 times.
✓ Branch 3 taken 35284 times.
2071348 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return true;
28486
4/4
✓ Branch 0 taken 712967 times.
✓ Branch 1 taken 1323097 times.
✓ Branch 2 taken 285105 times.
✓ Branch 3 taken 427862 times.
2036064 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return true;
28487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1608202 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1608202 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return true;
28488
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1608182 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
1608202 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return true;
28489 1608182 return false;
28490 2071348 }
28491
28492 3712721 int32_t getWpnPressed(int32_t itype)
28493 {
28494
4/4
✓ Branch 0 taken 177199 times.
✓ Branch 1 taken 3535522 times.
✓ Branch 2 taken 171856 times.
✓ Branch 3 taken 5343 times.
3712721 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
28495
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3706792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 586 times.
3707378 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
28496
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3706792 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3706792 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
28497
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3706792 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3706792 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
28498
28499 3706792 return -1;
28500 3712721 }
28501
28502 6418559 int32_t getRocsPressed()
28503 {
28504 6418559 int32_t jumpid = current_item_id(itype_rocs,true,true);
28505
28506
2/2
✓ Branch 0 taken 198594 times.
✓ Branch 1 taken 6219965 times.
6418559 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
28507
28508
2/2
✓ Branch 0 taken 6219965 times.
✓ Branch 1 taken 198594 times.
6418559 if (jumpid != -1)
28509 {
28510 198594 itemdata const& itm = itemsbuf[jumpid];
28511
28512 198594 byte intbtn = byte(itm.misc2&0xFF);
28513
1/2
✓ Branch 0 taken 198594 times.
✗ Branch 1 not taken.
198594 if(getIntBtnInput(intbtn, false, true, false, false, true))
28514 return jumpid; //not pressed
28515 198594 }
28516
28517
4/4
✓ Branch 0 taken 18558 times.
✓ Branch 1 taken 6400001 times.
✓ Branch 2 taken 17436 times.
✓ Branch 3 taken 1122 times.
6418559 if((itype_rocs==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
28518
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6417437 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6417437 if((itype_rocs==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
28519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6417437 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6417437 if((itype_rocs==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
28520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6417437 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6417437 if((itype_rocs==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
28521
28522 6417437 return -1;
28523 6418559 }
28524
28525 bool isItmPressed(int32_t itmid)
28526 {
28527 if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
28528 if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
28529 if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
28530 if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
28531 return false;
28532 }
28533
28534 781 void selectNextAWpn(int32_t type)
28535 {
28536
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(!get_bit(quest_rules,qr_SELECTAWPN))
28537 return;
28538
28539
2/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
781 int32_t ret = selectWpn_new(type, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28540 781 Awpn = Bweapon(ret);
28541 781 directItemA = directItem;
28542 781 game->awpn = ret;
28543 781 }
28544
28545 7560 void selectNextBWpn(int32_t type)
28546 {
28547
2/4
✓ Branch 0 taken 7560 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7560 times.
7560 int32_t ret = selectWpn_new(type, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28548 7560 Bwpn = Bweapon(ret);
28549 7560 directItemB = directItem;
28550 7560 game->bwpn = ret;
28551 7560 }
28552
28553 void selectNextXWpn(int32_t type)
28554 {
28555 if(!get_bit(quest_rules,qr_SET_XBUTTON_ITEMS)) return;
28556 int32_t ret = selectWpn_new(type, game->xwpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28557 Xwpn = Bweapon(ret);
28558 directItemX = directItem;
28559 game->xwpn = ret;
28560 }
28561
28562 void selectNextYWpn(int32_t type)
28563 {
28564 if(!get_bit(quest_rules,qr_SET_YBUTTON_ITEMS)) return;
28565 int32_t ret = selectWpn_new(type, game->ywpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
28566 Ywpn = Bweapon(ret);
28567 directItemY = directItem;
28568 game->ywpn = ret;
28569 }
28570
28571 50908 void verifyAWpn()
28572 {
28573
2/2
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 49889 times.
50908 if ( (game->forced_awpn != -1) )
28574 {
28575 1019 return;
28576 }
28577
2/2
✓ Branch 0 taken 46060 times.
✓ Branch 1 taken 3829 times.
49889 if(!get_bit(quest_rules,qr_SELECTAWPN))
28578 {
28579 46060 Awpn = selectSword();
28580 46060 game->awpn = 0xFF;
28581 46060 }
28582 else
28583 {
28584 3829 game->awpn = selectWpn_new(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
28585 3829 Awpn = Bweapon(game->awpn);
28586 3829 directItemA = directItem;
28587 }
28588 50908 }
28589
28590 48545 void verifyBWpn()
28591 {
28592
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 47532 times.
48545 if ( (game->forced_bwpn != -1) )
28593 {
28594 1013 return;
28595 }
28596 47532 game->bwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
28597 47532 Bwpn = Bweapon(game->bwpn);
28598 47532 directItemB = directItem;
28599 48545 }
28600
28601 48545 void verifyXWpn()
28602 {
28603
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 47532 times.
48545 if ( (game->forced_xwpn != -1) )
28604 {
28605 1013 return;
28606 }
28607
2/2
✓ Branch 0 taken 47468 times.
✓ Branch 1 taken 64 times.
47532 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
28608 64 game->xwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
28609 47468 else game->xwpn = -1;
28610 47532 Xwpn = Bweapon(game->xwpn);
28611 47532 directItemX = directItem;
28612 48545 }
28613
28614 48545 void verifyYWpn()
28615 {
28616
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 47532 times.
48545 if ( (game->forced_ywpn != -1) )
28617 {
28618 1013 return;
28619 }
28620
2/2
✓ Branch 0 taken 47468 times.
✓ Branch 1 taken 64 times.
47532 if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS))
28621 64 game->ywpn = selectWpn_new(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
28622 47468 else game->ywpn = -1;
28623 47532 Ywpn = Bweapon(game->ywpn);
28624 47532 directItemY = directItem;
28625 48545 }
28626
28627 48545 void verifyBothWeapons()
28628 {
28629 48545 verifyAWpn();
28630 48545 verifyBWpn();
28631 48545 verifyXWpn();
28632 48545 verifyYWpn();
28633 48545 }
28634
28635 61469 int32_t selectWpn_new(int32_t type, int32_t startpos, int32_t forbiddenpos, int32_t fp2, int32_t fp3)
28636 {
28637 //what will be returned when all else fails.
28638 //don't return the forbiddenpos... no matter what -DD
28639
28640 61469 int32_t failpos(0);
28641
28642
6/6
✓ Branch 0 taken 59065 times.
✓ Branch 1 taken 2404 times.
✓ Branch 2 taken 58903 times.
✓ Branch 3 taken 162 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 58899 times.
61469 if(startpos == forbiddenpos || startpos == fp2 || startpos == fp3)
28643 2570 failpos = 0xFF;
28644 58899 else failpos = startpos;
28645
28646 // verify startpos
28647
3/4
✓ Branch 0 taken 61469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2581 times.
✓ Branch 3 taken 58888 times.
61469 if(startpos < 0 || startpos >= 0xFF)
28648 2581 startpos = 0;
28649
28650
2/2
✓ Branch 0 taken 61208 times.
✓ Branch 1 taken 261 times.
61469 if(current_subscreen_active == NULL)
28651 261 return failpos;
28652
28653
4/4
✓ Branch 0 taken 9871 times.
✓ Branch 1 taken 51337 times.
✓ Branch 2 taken 721 times.
✓ Branch 3 taken 9150 times.
61208 if(type==SEL_VERIFY_RIGHT || type==SEL_VERIFY_LEFT)
28654 {
28655 52058 int32_t wpn = Bweapon(startpos);
28656
28657
6/8
✓ Branch 0 taken 48578 times.
✓ Branch 1 taken 3480 times.
✓ Branch 2 taken 48557 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 48557 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 48557 times.
52058 if(wpn != 0 && startpos != forbiddenpos && startpos != fp2 && startpos != fp3)
28658 {
28659 48557 return startpos;
28660 }
28661 3501 }
28662
28663 12651 int32_t p=-1;
28664 12651 int32_t curpos = startpos;
28665 12651 int32_t firstValidPos=-1;
28666
28667
2/2
✓ Branch 0 taken 2111 times.
✓ Branch 1 taken 276066 times.
278177 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
28668 {
28669
2/2
✓ Branch 0 taken 79249 times.
✓ Branch 1 taken 196817 times.
276066 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
28670 {
28671
4/4
✓ Branch 0 taken 155676 times.
✓ Branch 1 taken 41141 times.
✓ Branch 2 taken 145136 times.
✓ Branch 3 taken 10540 times.
196817 if(firstValidPos==-1 && current_subscreen_active->objects[i].d3>=0)
28672 {
28673 10540 firstValidPos=i;
28674 10540 }
28675
28676
2/2
✓ Branch 0 taken 186277 times.
✓ Branch 1 taken 10540 times.
196817 if(current_subscreen_active->objects[i].d3==curpos)
28677 {
28678 10540 p=i;
28679 10540 break;
28680 }
28681 186277 }
28682 265526 }
28683
28684
2/2
✓ Branch 0 taken 10540 times.
✓ Branch 1 taken 2111 times.
12651 if(p == -1)
28685 {
28686 //can't find the current position
28687 // Switch to a valid weapon if there is one; otherwise,
28688 // the selector can simply disappear
28689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2111 times.
2111 if(firstValidPos>=0)
28690 {
28691 return current_subscreen_active->objects[firstValidPos].d3;
28692 }
28693 //FAILURE
28694 else
28695 {
28696 2111 return failpos;
28697 }
28698 }
28699
28700 //remember we've been here
28701 10540 set<int32_t> oldPositions;
28702
1/2
✓ Branch 0 taken 10540 times.
✗ Branch 1 not taken.
10540 oldPositions.insert(curpos);
28703
28704 //1. Perform any shifts required by the above
28705 //2. If that's not possible, go to position 1 and reset the b weapon.
28706 //2a. -if we arrive at a position we've already visited, give up and stay there
28707 //3. Get the weapon at the new slot
28708 //4. If it's not possible, go to step 1.
28709
28710 35283 for(;;)
28711 {
28712 //shift
28713
4/5
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 5120 times.
✓ Branch 3 taken 30029 times.
✗ Branch 4 not taken.
35283 switch(type)
28714 {
28715 case SEL_LEFT:
28716 case SEL_VERIFY_LEFT:
28717 5120 curpos = current_subscreen_active->objects[p].d6;
28718 5120 break;
28719
28720 case SEL_RIGHT:
28721 case SEL_VERIFY_RIGHT:
28722 30029 curpos = current_subscreen_active->objects[p].d7;
28723 30029 break;
28724
28725 case SEL_DOWN:
28726 36 curpos = current_subscreen_active->objects[p].d5;
28727 36 break;
28728
28729 case SEL_UP:
28730 98 curpos = current_subscreen_active->objects[p].d4;
28731 98 break;
28732 }
28733
28734 //find our new position
28735 35283 p = -1;
28736
28737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140909 times.
1140909 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
28738 {
28739
2/2
✓ Branch 0 taken 254845 times.
✓ Branch 1 taken 886064 times.
1140909 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
28740 {
28741
2/2
✓ Branch 0 taken 850781 times.
✓ Branch 1 taken 35283 times.
886064 if(current_subscreen_active->objects[i].d3==curpos)
28742 {
28743 35283 p=i;
28744 35283 break;
28745 }
28746 850781 }
28747 1105626 }
28748
28749
1/2
✓ Branch 0 taken 35283 times.
✗ Branch 1 not taken.
35283 if(p == -1)
28750 {
28751 //can't find the current position
28752 //FAILURE
28753 return failpos;
28754 }
28755
28756 //if we've already been here, give up
28757
3/4
✓ Branch 0 taken 35283 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33644 times.
✓ Branch 3 taken 1639 times.
35283 if(oldPositions.find(curpos) != oldPositions.end())
28758 {
28759 1639 return failpos;
28760 }
28761
28762 //else, remember we've been here
28763
1/2
✓ Branch 0 taken 33644 times.
✗ Branch 1 not taken.
33644 oldPositions.insert(curpos);
28764
28765 //see if this weapon is acceptable
28766
9/10
✓ Branch 0 taken 33644 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9130 times.
✓ Branch 3 taken 24514 times.
✓ Branch 4 taken 8919 times.
✓ Branch 5 taken 211 times.
✓ Branch 6 taken 8909 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 8901 times.
33644 if(Bweapon(curpos) != 0 && curpos != forbiddenpos && curpos != fp2 && curpos != fp3)
28767 8901 return curpos;
28768
28769 //keep going otherwise
28770 }
28771 61469 }
28772
28773 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
28774 46157 int32_t selectSword()
28775 {
28776 46157 auto ret = current_item_id(itype_sword);
28777
2/2
✓ Branch 0 taken 1396 times.
✓ Branch 1 taken 44761 times.
46157 if(ret == -1) return 0;
28778 44761 return ret;
28779 46157 }
28780
28781 // Adding code here for allowing hardcoding a button to a specific itemclass.
28782 int32_t selectItemclass(int32_t itemclass)
28783 {
28784 int32_t ret = current_item_id(itemclass);
28785
28786 if(ret == -1)
28787 ret = 0;
28788
28789 return ret;
28790 }
28791
28792 // Used for the 'Pickup Hearts' item pickup condition.
28793 111 bool canget(int32_t id)
28794 {
28795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
28796 }
28797
28798 31 void dospecialmoney(int32_t index)
28799 {
28800 31 int32_t tmp=currscr>=128?1:0;
28801 31 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
28802
28803
4/7
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
31 switch(tmpscr[tmp].room)
28804 {
28805 case rINFO: // pay for info
28806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
28807 {
28808
28809
28810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!current_item_power(itype_wallet))
28811 {
28812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (game->get_spendable_rupies() < abs(prices[priceindex]))
28813 return;
28814 2 int32_t tmpprice = -abs(prices[priceindex]);
28815 2 int32_t total = game->get_drupy()-tmpprice;
28816 2 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28817 2 game->set_drupy(game->get_drupy()-total);
28818 //game->change_drupy(-abs(prices[priceindex]));
28819 2 }
28820
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( current_item_power(itype_wallet)>0 )
28821 {
28822 game->change_drupy(0);
28823 }
28824 2 }
28825 2 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
28826 2 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
28827 2 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
28828 2 clear_bitmap(pricesdisplaybuf);
28829 2 set_clip_state(pricesdisplaybuf, 1);
28830 2 items.del(0);
28831
28832
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for(int32_t i=0; i<items.Count(); i++)
28833 6 ((item*)items.spr(i))->pickup=ipDUMMY;
28834
28835 // Prevent the prices from being displayed anymore
28836
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for(int32_t i=0; i<3; i++)
28837 {
28838 6 prices[i] = 0;
28839 6 }
28840
28841 2 break;
28842
28843 case rMONEY: // secret money
28844 {
28845 14 ((item*)items.spr(0))->pickup = ipDUMMY;
28846
28847 14 prices[0] = tmpscr[tmp].catchall;
28848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (!current_item_power(itype_wallet))
28849 14 game->change_drupy(prices[0]);
28850 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
28851
28852 14 putprices(false);
28853
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28854 14 break;
28855 }
28856
28857 case rGAMBLE: // gamble
28858 {
28859 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
28860
28861 unsigned si=(zc_oldrand()%24)*3;
28862
28863 for(int32_t i=0; i<3; i++)
28864 prices[i]=gambledat[si++];
28865
28866 game->set_drupy(game->get_drupy()+prices[priceindex]);
28867 putprices(true);
28868
28869 for(int32_t i=1; i<4; i++)
28870 ((item*)items.spr(i))->pickup=ipDUMMY;
28871 }
28872 break;
28873
28874 case rBOMBS:
28875 {
28876
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
28877 return;
28878
28879 4 int32_t price = -tmpscr[tmp].catchall;
28880 4 int32_t wmedal = current_item_id(itype_wealthmedal);
28881
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(wmedal >= 0)
28882 {
28883 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
28884 price*=(itemsbuf[wmedal].misc1/100.0);
28885 else
28886 price+=itemsbuf[wmedal].misc1;
28887 }
28888
28889 4 int32_t total = game->get_drupy()-price;
28890 4 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28891 4 game->set_drupy(game->get_drupy()-total);
28892 //game->set_drupy(game->get_drupy()+price);
28893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28894 4 game->change_maxbombs(4);
28895 4 game->set_bombs(game->get_maxbombs());
28896 {
28897 4 int32_t div = zinit.bomb_ratio;
28898
28899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(div > 0)
28900 4 game->change_maxcounter(4/div, 6);
28901 }
28902
28903 //also give Hero an actual Bomb item
28904
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<MAXITEMS; i++)
28905 {
28906
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1018 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
1024 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
28907 4 getitem(i, true, true);
28908 1024 }
28909
28910 4 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
28911 4 fadeclk=66;
28912 4 dismissmsg();
28913 4 clear_bitmap(pricesdisplaybuf);
28914 4 set_clip_state(pricesdisplaybuf, 1);
28915 // putscr(scrollbuf,0,0,tmpscr);
28916 4 verifyBothWeapons();
28917 4 break;
28918 }
28919
28920 case rARROWS:
28921 {
28922 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
28923 return;
28924
28925 int32_t price = -tmpscr[tmp].catchall;
28926 int32_t wmedal = current_item_id(itype_wealthmedal);
28927 if(wmedal >= 0)
28928 {
28929 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
28930 price*=(itemsbuf[wmedal].misc1/100.0);
28931 else
28932 price+=itemsbuf[wmedal].misc1;
28933 }
28934
28935 int32_t total = game->get_drupy()-price;
28936 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28937 game->set_drupy(game->get_drupy()-total);
28938
28939 //game->set_drupy(game->get_drupy()+price);
28940 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28941 game->change_maxarrows(10);
28942 game->set_arrows(game->get_maxarrows());
28943 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
28944 fadeclk=66;
28945 dismissmsg();
28946 clear_bitmap(pricesdisplaybuf);
28947 set_clip_state(pricesdisplaybuf, 1);
28948 // putscr(scrollbuf,0,0,tmpscr);
28949 verifyBothWeapons();
28950 break;
28951 }
28952
28953 case rSWINDLE:
28954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(items.spr(index)->id==iRupy)
28955 {
28956
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
28957 return;
28958 11 int32_t tmpprice = -tmpscr[tmp].catchall;
28959 11 int32_t total = game->get_drupy()-tmpprice;
28960 11 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
28961 11 game->set_drupy(game->get_drupy()-total);
28962 11 }
28963 else
28964 {
28965 if(game->get_maxlife()<=game->get_hp_per_heart())
28966 return;
28967
28968 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
28969 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
28970 }
28971
28972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
28973 11 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
28974 11 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
28975 11 fadeclk=66;
28976 11 dismissmsg();
28977 11 clear_bitmap(pricesdisplaybuf);
28978 11 set_clip_state(pricesdisplaybuf, 1);
28979 // putscr(scrollbuf,0,0,tmpscr);
28980 11 break;
28981 }
28982 31 }
28983
28984 9594 void getitem(int32_t id, bool nosound, bool doRunPassive)
28985 {
28986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9594 times.
9594 if(unsigned(id) >= MAXITEMS)
28987 return;
28988
28989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9594 times.
9594 if (replay_is_active())
28990
1/2
✓ Branch 0 taken 9594 times.
✗ Branch 1 not taken.
9594 replay_step_comment(fmt::format("getitem {}", item_string[id]));
28991
28992
2/2
✓ Branch 0 taken 9588 times.
✓ Branch 1 taken 6 times.
9594 if(get_bit(quest_rules,qr_SCC_ITEM_COMBINES_ITEMS))
28993 {
28994 6 int32_t nextitem = -1;
28995 6 do
28996 {
28997 6 nextitem = -1;
28998
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
28999 // Item upgrade routine.
29000 {
29001
29002 for(int32_t i=0; i<MAXITEMS; i++)
29003 {
29004 // Find the item which is as close to this item's fam_type as possible.
29005 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
29006 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
29007 {
29008 nextitem = i;
29009 }
29010 }
29011
29012 if(nextitem>-1)
29013 {
29014 id = nextitem;
29015 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
29016 break; //no looping
29017 }
29018 }
29019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 } while(nextitem > -1);
29020 6 }
29021
29022 9594 itemdata const& idat = itemsbuf[id&0xFF];
29023
29024 19188 bool equipment = idat.flags &
29025 9594 ((idat.family == itype_triforcepiece) ? ITEM_FLAG8 : ITEM_GAMEDATA);
29026
29027
2/2
✓ Branch 0 taken 8664 times.
✓ Branch 1 taken 930 times.
9594 if(equipment)
29028 {
29029 // Fix boomerang sounds.
29030 930 int32_t itemid = current_item_id(idat.family);
29031
29032
4/6
✓ Branch 0 taken 547 times.
✓ Branch 1 taken 383 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
930 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_divineprotection
29033
5/6
✓ Branch 0 taken 535 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 534 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 533 times.
✓ Branch 5 taken 1 times.
535 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
29034 547 && sfx_allocated(itemsbuf[itemid].usesound)
29035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 547 times.
547 && idat.usesound != itemsbuf[itemid].usesound)
29036 {
29037 stop_sfx(itemsbuf[itemid].usesound);
29038 cont_sfx(idat.usesound);
29039 }
29040
29041 930 int32_t curitm = current_item_id(idat.family);
29042
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
930 if(!get_bit(quest_rules,qr_KEEPOLD_APPLIES_RETROACTIVELY)
29043
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
930 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
29044 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
29045 {
29046 930 game->set_item(id,true);
29047 930 passiveitem_script(id, doRunPassive);
29048 930 }
29049
29050
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 627 times.
930 if(!(idat.flags & ITEM_KEEPOLD))
29051 {
29052
3/4
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 513 times.
627 if(!get_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
29053 {
29054 114 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
29055 114 }
29056 627 }
29057
29058 // NES consistency: replace all flying boomerangs with the current boomerang.
29059
2/2
✓ Branch 0 taken 901 times.
✓ Branch 1 taken 29 times.
930 if(idat.family==itype_brang)
29060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 for(int32_t i=0; i<Lwpns.Count(); i++)
29061 {
29062 weapon *w = ((weapon*)Lwpns.spr(i));
29063
29064 if(w->id==wBrang)
29065 {
29066 w->LOADGFX(idat.wpn);
29067 }
29068 29 }
29069 930 }
29070
29071
2/2
✓ Branch 0 taken 1569 times.
✓ Branch 1 taken 8025 times.
9594 if(idat.count!=-1)
29072 {
29073
2/2
✓ Branch 0 taken 7815 times.
✓ Branch 1 taken 210 times.
8025 if(idat.setmax)
29074 {
29075 // Bomb bags are a special case; they may be set not to increase super bombs
29076
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 203 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
210 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
29077 {
29078 int32_t max = game->get_maxbombs();
29079
29080 if(max<idat.max) max=idat.max;
29081
29082 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
29083 }
29084 else
29085 {
29086 210 int32_t max = game->get_maxcounter(idat.count);
29087
29088
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 177 times.
210 if(max<idat.max) max=idat.max;
29089
29090
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 61 times.
210 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
29091 }
29092 210 }
29093
29094 // Amount is an uint16_t, but the range is -9999 to 16383
29095 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
29096
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 7828 times.
8025 if(idat.amount&0x3FFF)
29097 {
29098
2/2
✓ Branch 0 taken 5022 times.
✓ Branch 1 taken 2806 times.
7828 if(idat.amount&0x8000)
29099 10044 game->set_dcounter(
29100
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5021 times.
5022 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29101 else
29102 {
29103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2806 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2806 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
29104 game->set_counter(0, idat.count);
29105 else
29106 // This is too confusing to try and change...
29107
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2806 times.
✓ Branch 2 taken 1284 times.
✓ Branch 3 taken 1522 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1284 times.
2806 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
29108 }
29109 7828 }
29110 8025 }
29111
29112
4/4
✓ Branch 0 taken 9591 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 228 times.
✓ Branch 3 taken 9363 times.
9594 if(idat.playsound&&!nosound)
29113 {
29114 9363 sfx(idat.playsound);
29115 9363 }
29116
29117 //add lower-level items
29118
2/2
✓ Branch 0 taken 9566 times.
✓ Branch 1 taken 28 times.
9594 if(idat.flags&ITEM_GAINOLD)
29119 {
29120
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 28 times.
52 for(int32_t i=idat.fam_type-1; i>0; i--)
29121 {
29122 24 int32_t potid = getItemID(itemsbuf, idat.family, i);
29123
29124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(potid != -1)
29125 {
29126 24 game->set_item(potid, true);
29127 24 }
29128 24 }
29129 28 }
29130
29131
11/14
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 8606 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 385 times.
✓ Branch 6 taken 41 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 57 times.
✓ Branch 9 taken 53 times.
✓ Branch 10 taken 27 times.
✓ Branch 11 taken 356 times.
✓ Branch 12 taken 35 times.
✓ Branch 13 taken 5 times.
9594 switch(idat.family)
29132 {
29133 case itype_itmbundle:
29134 {
29135 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
29136 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
29137 bool pscript = (idat.flags & ITEM_FLAG1);
29138 for(auto q = 0; q < 10; ++q)
29139 {
29140 if(unsigned(ids[q]) >= MAXITEMS) continue;
29141 if(pscript)
29142 collectitem_script(ids[q]);
29143 getitem(ids[q], true, true);
29144 }
29145 }
29146 break;
29147
29148 case itype_progressive_itm:
29149 {
29150 int32_t newid = get_progressive_item(idat);
29151 if(newid > -1)
29152 getitem(newid, nosound, true);
29153 }
29154 break;
29155
29156 case itype_bottlefill:
29157 {
29158 if(idat.misc1)
29159 {
29160 game->fillBottle(idat.misc1);
29161 }
29162 }
29163 break;
29164
29165 case itype_clock:
29166 {
29167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
385 if(idat.flags & ITEM_FLAG1) //Active use, not passive
29168 break;
29169
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
29170 break;
29171 385 setClock(watch=true);
29172
29173
2/2
✓ Branch 0 taken 197120 times.
✓ Branch 1 taken 385 times.
197505 for(int32_t i=0; i<eMAXGUYS; i++)
29174 197120 clock_zoras[i]=0;
29175
29176 385 clockclk=itemsbuf[id&0xFF].misc1;
29177 385 sfx(idat.usesound);
29178 }
29179 385 break;
29180
29181 case itype_lkey:
29182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
29183 41 break;
29184
29185 case itype_ring:
29186 case itype_magicring:
29187
6/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 1 times.
25 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
29188 {
29189 24 ringcolor(false);
29190 24 }
29191 25 break;
29192
29193 case itype_whispring:
29194 {
29195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(idat.flags & ITEM_FLAG1)
29196 {
29197
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
29198
29199
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
29200 4 }
29201
29202
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(idat.power==0)
29203 {
29204 2 setSwordClk(0);
29205 2 setItemClk(0);
29206 2 }
29207
29208 4 break;
29209 }
29210
29211
29212 case itype_map:
29213 57 game->lvlitems[dlevel]|=liMAP;
29214 57 break;
29215
29216 case itype_compass:
29217 53 game->lvlitems[dlevel]|=liCOMPASS;
29218 53 break;
29219
29220 case itype_bosskey:
29221 27 game->lvlitems[dlevel]|=liBOSSKEY;
29222 27 break;
29223
29224 case itype_fairy:
29225
29226
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✓ Branch 2 taken 119 times.
✓ Branch 3 taken 237 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 119 times.
356 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
29227
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 302 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 54 times.
356 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
29228 356 break;
29229
29230 case itype_heartpiece:
29231 35 game->change_HCpieces(1);
29232
29233
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
35 if(game->get_HCpieces()<game->get_hcp_per_hc())
29234 28 break;
29235
29236 7 game->set_HCpieces(0);
29237
29238 7 getitem(heart_container_id());
29239 7 break;
29240
29241 case itype_killem:
29242 {
29243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(idat.flags & ITEM_FLAG1) //Active use, not passive
29244 break;
29245 5 kill_em_all();
29246 5 sfx(idat.usesound);
29247 }
29248 5 break;
29249 }
29250
29251 9594 flushItemCache();
29252 9594 update_subscreens();
29253 9594 load_Sitems(&QMisc);
29254 9594 verifyBothWeapons();
29255 9594 }
29256
29257 void takeitem(int32_t id)
29258 {
29259 game->set_item(id, false);
29260 itemdata const& idat = itemsbuf[id];
29261
29262 /* Lower the counters! */
29263 if(idat.count!=-1)
29264 {
29265 if(idat.setmax)
29266 {
29267 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
29268 }
29269
29270 if(idat.amount&0x3FFF)
29271 {
29272 if(idat.amount&0x8000)
29273 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29274 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29275 }
29276 }
29277
29278 switch(itemsbuf[id&0xFF].family)
29279 {
29280 // NES consistency: replace all flying boomerangs with the current boomerang.
29281 case itype_brang:
29282 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
29283 {
29284 weapon *w = ((weapon*)Lwpns.spr(i));
29285
29286 if(w->id==wBrang)
29287 {
29288 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
29289 }
29290 }
29291
29292 break;
29293
29294 case itype_itmbundle:
29295 {
29296 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
29297 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
29298 for(auto q = 0; q < 10; ++q)
29299 {
29300 if(unsigned(ids[q]) >= MAXITEMS) continue;
29301 takeitem(ids[q]);
29302 }
29303 }
29304 break;
29305
29306 case itype_progressive_itm:
29307 {
29308 int32_t newid = get_progressive_item(idat, true);
29309 if(newid > -1)
29310 takeitem(newid);
29311 }
29312 break;
29313
29314 case itype_heartpiece:
29315 if(game->get_maxlife()>game->get_hp_per_heart())
29316 {
29317 if(game->get_HCpieces()==0)
29318 {
29319 game->set_HCpieces(game->get_hcp_per_hc());
29320 takeitem(iHeartC);
29321 }
29322
29323 game->change_HCpieces(-1);
29324 }
29325 break;
29326
29327 case itype_map:
29328 game->lvlitems[dlevel]&=~liMAP;
29329 break;
29330
29331 case itype_compass:
29332 game->lvlitems[dlevel]&=~liCOMPASS;
29333 break;
29334
29335 case itype_bosskey:
29336 game->lvlitems[dlevel]&=~liBOSSKEY;
29337 break;
29338
29339 case itype_lkey:
29340 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
29341 break;
29342
29343 case itype_ring:
29344 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
29345 {
29346 ringcolor(false);
29347 }
29348 break;
29349 }
29350 }
29351
29352 6928 void post_item_collect()
29353 {
29354 6928 std::vector<int32_t> &ev = FFCore.eventData;
29355 6928 ev.clear();
29356
29357 6928 throwGenScriptEvent(GENSCR_EVENT_POST_COLLECT_ITEM);
29358 6928 }
29359
29360 6978 void HeroClass::handle_triforce(int32_t id)
29361 {
29362
1/2
✓ Branch 0 taken 6978 times.
✗ Branch 1 not taken.
6978 if(unsigned(id) >= MAXITEMS)
29363 return;
29364 6978 itemdata const& itm = itemsbuf[id];
29365
2/3
✓ Branch 0 taken 6911 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
6978 switch(itm.family)
29366 {
29367 case itype_itmbundle:
29368 {
29369 int ids[10] = {itm.misc1, itm.misc2, itm.misc3, itm.misc4, itm.misc5,
29370 itm.misc6, itm.misc7, itm.misc8, itm.misc9, itm.misc10};
29371 for(auto q = 0; q < 10; ++q)
29372 {
29373 if(unsigned(ids[q]) >= MAXITEMS) continue;
29374 handle_triforce(ids[q]);
29375 }
29376 }
29377 break;
29378 case itype_triforcepiece:
29379 {
29380
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 60 times.
67 if(itm.misc2>0)
29381 60 getTriforce(id); //small
29382 7 else getBigTri(id); //big
29383 }
29384 67 break;
29385 }
29386 6978 }
29387
29388 // Attempt to pick up an item. (-1 = check items touching Hero.)
29389 6409330 void HeroClass::checkitems(int32_t index)
29390 {
29391 6409330 int32_t tmp=currscr>=128?1:0;
29392
29393
2/2
✓ Branch 0 taken 1451 times.
✓ Branch 1 taken 6407879 times.
6409330 if(index==-1)
29394 {
29395
2/2
✓ Branch 0 taken 1310004 times.
✓ Branch 1 taken 6407879 times.
7717883 for(auto ind = items.Count()-1; ind >= 0; --ind)
29396 {
29397 1310004 item* itm = (item*)items.spr(ind);
29398
2/2
✓ Branch 0 taken 1309992 times.
✓ Branch 1 taken 12 times.
1310004 if(itm->get_forcegrab())
29399 {
29400 12 checkitems(ind);
29401 12 }
29402 1310004 }
29403
2/2
✓ Branch 0 taken 712074 times.
✓ Branch 1 taken 5695805 times.
6407879 if(diagonalMovement)
29404 {
29405 712074 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
29406 712074 }
29407 5695805 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
29408 6407879 }
29409
29410
2/2
✓ Branch 0 taken 50800 times.
✓ Branch 1 taken 6358530 times.
6409330 if(index==-1)
29411 6358530 return;
29412
29413 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
29414 // return;
29415 50800 item* ptr = (item*)items.spr(index);
29416 50800 int32_t pickup = ptr->pickup;
29417 50800 int8_t exstate = ptr->pickupexstate;
29418 50800 int32_t PriceIndex = ptr->PriceIndex;
29419 50800 int32_t id2 = ptr->id;
29420 50800 int32_t holdid = ptr->id;
29421 50800 int32_t pstr = ptr->pstring;
29422 50800 int32_t pstr_flags = ptr->pickup_string_flags;
29423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50800 times.
50800 if(ptr->fallclk > 0) return; //Don't pick up a falling item
29424
29425
1/2
✓ Branch 0 taken 50800 times.
✗ Branch 1 not taken.
50800 if(itemsbuf[id2].family == itype_progressive_itm)
29426 {
29427 int32_t newid = get_progressive_item(itemsbuf[id2]);
29428 if(newid > -1)
29429 {
29430 id2 = newid;
29431 holdid = newid;
29432 pstr = itemsbuf[newid].pstring;
29433 pstr_flags = itemsbuf[newid].pickup_string_flags;
29434 }
29435 }
29436
29437
2/2
✓ Branch 0 taken 49934 times.
✓ Branch 1 taken 866 times.
50800 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
29438
29439
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50798 times.
50800 if(bottledummy) //Dummy bullshit!
29440 {
29441
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!game->canFillBottle())
29442 return;
29443
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
29444 {
29445 if(!current_item_power(itype_wallet))
29446 {
29447 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
29448 int32_t tmpprice = -abs(prices[PriceIndex]);
29449 //game->change_drupy(-abs(prices[priceindex]));
29450 int32_t total = game->get_drupy()-tmpprice;
29451 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29452 game->set_drupy(game->get_drupy()-total);
29453 }
29454 else //infinite wallet
29455 {
29456 game->change_drupy(0);
29457 }
29458 }
29459 2 boughtsomething=true;
29460 //make the other shop items untouchable after
29461 //you buy something
29462 2 int32_t count = 0;
29463
29464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<3; i++)
29465 {
29466 if(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[i] != 0)
29467 {
29468 ++count;
29469 }
29470 }
29471
29472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<items.Count(); i++)
29473 {
29474 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
29475 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
29476 }
29477
29478 2 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
29479 2 id2 = find_bottle_for_slot(slot);
29480 2 ptr->id = id2;
29481 2 pstr = 0;
29482 2 pickup |= ipHOLDUP;
29483 2 }
29484 else
29485 {
29486 50798 std::vector<int32_t> &ev = FFCore.eventData;
29487 50798 ev.clear();
29488 50798 ev.push_back(id2*10000);
29489 50798 ev.push_back(pickup*10000);
29490 50798 ev.push_back(pstr*10000);
29491 50798 ev.push_back(pstr_flags*10000);
29492 50798 ev.push_back(0);
29493 50798 ev.push_back(ptr->getUID());
29494 50798 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
29495 50798 ev.push_back(0);
29496
29497 50798 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
29498 50798 bool nullify = ev[4] != 0;
29499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50798 times.
50798 if(nullify) return;
29500 50798 id2 = ev[0]/10000;
29501 50798 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
29502 50798 pstr = ev[2] / 10000;
29503 50798 pstr_flags = ev[3] / 10000;
29504
29505
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50798 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
29506 return; //No picking these up unless you have a bottle to fill!
29507
29508
5/6
✓ Branch 0 taken 48415 times.
✓ Branch 1 taken 2383 times.
✓ Branch 2 taken 42740 times.
✓ Branch 3 taken 5675 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 42740 times.
50798 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
29509
2/2
✓ Branch 0 taken 42620 times.
✓ Branch 1 taken 120 times.
42740 if(ptr->id!=iFairyMoving)
29510 // wait for it to stop flashing, doesn't check for other items yet
29511 42620 return;
29512
29513
2/2
✓ Branch 0 taken 8151 times.
✓ Branch 1 taken 27 times.
8178 if(pickup&ipENEMY) // item was being carried by enemy
29514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
54 if(more_carried_items()<=1) // 1 includes this own item.
29515 27 hasitem &= ~2;
29516
29517
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 7690 times.
8178 if(pickup&ipDUMMY) // dummy item (usually a rupee)
29518 {
29519
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 31 times.
488 if(pickup&ipMONEY)
29520 31 dospecialmoney(index);
29521
29522 488 return;
29523 }
29524
29525
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7690 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7690 if(get_bit(quest_rules,qr_HEARTSREQUIREDFIX) && !canget(id2))
29526 return;
29527
29528 7690 int32_t nextitem = -1;
29529 7690 do
29530 {
29531 7690 nextitem = -1;
29532
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 7676 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 10 times.
7690 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
29533 // Item upgrade routine.
29534 {
29535
29536
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 10 times.
2570 for(int32_t i=0; i<MAXITEMS; i++)
29537 {
29538 // Find the item which is as close to this item's fam_type as possible.
29539
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2538 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 10 times.
2560 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
29540
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
22 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
29541 {
29542 10 nextitem = i;
29543 10 }
29544 2560 }
29545
29546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nextitem>-1)
29547 {
29548 10 id2 = nextitem;
29549
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(get_bit(quest_rules,qr_ITEMCOMBINE_NEW_PSTR))
29550 {
29551 pstr = itemsbuf[id2].pstring;
29552 pstr_flags = itemsbuf[id2].pickup_string_flags;
29553 }
29554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
29555 10 break; //no looping
29556 }
29557 }
29558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 } while(nextitem > -1);
29559
29560
2/2
✓ Branch 0 taken 6824 times.
✓ Branch 1 taken 866 times.
7690 if(pickup&ipCHECK) // check restrictions
29561
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 648 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 107 times.
866 switch(tmpscr[tmp].room)
29562 {
29563 case rSP_ITEM: // special item
29564
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 19 times.
111 if(!canget(id2)) // These ones always need the Hearts Required check
29565 19 return;
29566
29567 92 break;
29568
29569 case rP_SHOP: // potion shop
29570
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 14 times.
107 if(msg_active)
29571 93 return;
29572 [[fallthrough]];
29573 case rSHOP: // shop
29574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662 times.
662 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
29575 {
29576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662 times.
662 if(!current_item_power(itype_wallet))
29577 {
29578
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 62 times.
662 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
29579 62 int32_t tmpprice = -abs(prices[PriceIndex]);
29580 //game->change_drupy(-abs(prices[priceindex]));
29581 62 int32_t total = game->get_drupy()-tmpprice;
29582 62 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29583 62 game->set_drupy(game->get_drupy()-total);
29584 62 }
29585 else //infinite wallet
29586 {
29587 game->change_drupy(0);
29588 }
29589 62 }
29590 62 boughtsomething=true;
29591 //make the other shop items untouchable after
29592 //you buy something
29593 62 int32_t count = 0;
29594
29595
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 62 times.
248 for(int32_t i=0; i<3; i++)
29596 {
29597
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 177 times.
186 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
29598 {
29599 177 ++count;
29600 177 }
29601 186 }
29602
29603
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 62 times.
301 for(int32_t i=0; i<items.Count(); i++)
29604 {
29605
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 115 times.
239 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
29606 115 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
29607 239 }
29608
29609 62 break;
29610 154 }
29611
29612
2/2
✓ Branch 0 taken 771 times.
✓ Branch 1 taken 6207 times.
6978 if(pickup&ipONETIME) // set mITEM for one-time-only items
29613 {
29614 771 setmapflag(mITEM);
29615
29616 //Okay so having old source files is a godsend. You wanna know why?
29617 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
29618 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
29619 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
29620 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
29621 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
29622
29623 /*
29624 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
29625 // broken behavior from early ZC versions. If you change things here please comment on it's purpose.
29626
29627 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
29628 // What is etc?! We need to check for every valid state here. ~Gleeok
29629 if(get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW))
29630 {
29631 // Most older quests need one-time-pickups to not remove special items, etc.
29632 if(tmpscr->room==rGRUMBLE)
29633 {
29634 setmapflag(mSPECIALITEM);
29635 }
29636 }
29637 */
29638 771 }
29639
2/2
✓ Branch 0 taken 5943 times.
✓ Branch 1 taken 264 times.
6207 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
29640
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 74 times.
264 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29641
29642
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6977 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
6978 if(exstate > -1 && exstate < 32)
29643 {
29644 1 setxmapflag(1<<exstate);
29645 1 }
29646
29647
2/2
✓ Branch 0 taken 6977 times.
✓ Branch 1 taken 1 times.
6978 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
29648 {
29649
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
29650 1 hidden_entrance(0, true, false, -5);
29651 1 }
29652
29653 6978 collectitem_script(id2);
29654 6978 getitem(id2, false, true);
29655 }
29656
29657
2/2
✓ Branch 0 taken 542 times.
✓ Branch 1 taken 6438 times.
6980 if(pickup&ipHOLDUP)
29658 {
29659 542 attackclk=0;
29660 542 reset_swordcharge();
29661
29662
3/4
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 534 times.
542 if(action!=swimming && !IsSideSwim())
29663 534 reset_hookshot();
29664
29665
2/2
✓ Branch 0 taken 373 times.
✓ Branch 1 taken 165 times.
542 if(msg_onscreen)
29666 {
29667 165 dismissmsg();
29668 165 }
29669
29670 538 clear_bitmap(pricesdisplaybuf);
29671
29672
6/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
539 if(get_bit(quest_rules, qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
29673
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 (get_bit(quest_rules, qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
29674 {
29675 539 fadeclk=66;
29676 539 }
29677
29678
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 538 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
540 if(id2!=iBombs || action==swimming || get_bit(quest_rules,qr_BOMBHOLDFIX))
29679 {
29680 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
29681
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 532 times.
538 if(action==swimming)
29682 {
29683 6 action=waterhold1; FFCore.setHeroAction(waterhold1);
29684 6 }
29685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 else if(IsSideSwim())
29686 {
29687 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
29688 }
29689 else
29690 {
29691 532 action=landhold1; FFCore.setHeroAction(landhold1);
29692 }
29693
29694
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 176 times.
538 if(ptr->twohand)
29695 {
29696
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 175 times.
176 if(action==waterhold1)
29697 {
29698 1 action=waterhold2; FFCore.setHeroAction(waterhold2);
29699 1 }
29700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175 times.
175 else if(action==sidewaterhold1)
29701 {
29702 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
29703 }
29704 else
29705 {
29706 175 action=landhold2; FFCore.setHeroAction(landhold2);
29707 }
29708 176 }
29709
29710 538 holdclk=130;
29711
29712 //restart music
29713
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 77 times.
538 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0)
29714 77 music_stop();
29715
29716 538 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
29717 538 freeze_guys=true;
29718 //show the info string
29719
29720
29721 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
29722
29723 538 int32_t shop_pstr = 0;
29724
2/2
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 75 times.
538 if (PriceIndex > -1)
29725 {
29726
2/3
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
75 switch(tmpscr[tmp].room)
29727 {
29728 case rSHOP:
29729 48 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
29730 48 break;
29731 case rBOTTLESHOP:
29732 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
29733 break;
29734 }
29735 75 }
29736
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 538 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 538 times.
538 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
29737 {
29738 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
29739 {
29740 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
29741 }
29742 else pstr = 0;
29743 if(shop_pstr)
29744 {
29745 donewmsg(shop_pstr);
29746 enqueued_str = pstr;
29747 }
29748 else if(pstr)
29749 {
29750 donewmsg(pstr);
29751 }
29752 }
29753
29754 538 }
29755
29756
3/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
540 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
29757 {
29758 480 sfx(tmpscr[0].holdupsfx);
29759 480 }
29760
29761 540 ptr->set_forcegrab(false);
29762 540 items.del(index);
29763
29764
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 540 times.
663 for(int32_t i=0; i<Lwpns.Count(); i++)
29765 {
29766 123 weapon *w = (weapon*)Lwpns.spr(i);
29767
29768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(w->dragging==index)
29769 {
29770 w->dragging=-1;
29771 }
29772
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 else if(w->dragging>index)
29773 {
29774 w->dragging-=1;
29775 }
29776 123 }
29777
29778 // clear up shop stuff
29779
4/4
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 272 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 73 times.
540 if((isdungeon()==0)&&(index!=0))
29780 {
29781
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 57 times.
73 if(boughtsomething)
29782 {
29783 57 fadeclk=66;
29784
29785
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
57 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
29786 {
29787 57 items.del(0);
29788
29789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 for(int32_t i=0; i<Lwpns.Count(); i++)
29790 {
29791 weapon *w = (weapon*)Lwpns.spr(i);
29792
29793 if(w->dragging==0)
29794 {
29795 w->dragging=-1;
29796 }
29797 else if(w->dragging>0)
29798 {
29799 w->dragging-=1;
29800 }
29801 }
29802 57 }
29803 57 }
29804
29805
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(msg_onscreen)
29806 {
29807 dismissmsg();
29808 }
29809
29810 73 clear_bitmap(pricesdisplaybuf);
29811 73 set_clip_state(pricesdisplaybuf, 1);
29812 73 }
29813
29814 // items.del(index);
29815 540 }
29816 else
29817 {
29818 6438 ptr->set_forcegrab(false);
29819 6438 items.del(index);
29820
29821
2/2
✓ Branch 0 taken 5457 times.
✓ Branch 1 taken 6438 times.
11895 for(int32_t i=0; i<Lwpns.Count(); i++)
29822 {
29823 5457 weapon *w = (weapon*)Lwpns.spr(i);
29824
29825
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 5420 times.
5457 if(w->dragging==index)
29826 {
29827 37 w->dragging=-1;
29828 37 }
29829
1/2
✓ Branch 0 taken 5420 times.
✗ Branch 1 not taken.
5420 else if(w->dragging>index)
29830 {
29831 w->dragging-=1;
29832 }
29833 5457 }
29834
29835
2/2
✓ Branch 0 taken 6429 times.
✓ Branch 1 taken 9 times.
6438 if(msg_onscreen)
29836 {
29837 9 dismissmsg();
29838 9 }
29839
29840 //general item pickup message
29841 //show the info string
29842 //non-held
29843 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
29844
3/6
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 6306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6438 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
29845
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6437 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6437 times.
6438 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
29846 {
29847
6/12
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
1 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
29848 {
29849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
29850 1 }
29851 else pstr = 0;
29852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(shop_pstr)
29853 {
29854 donewmsg(shop_pstr);
29855 enqueued_str = pstr;
29856 }
29857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(pstr)
29858 {
29859 1 donewmsg(pstr);
29860 1 }
29861 1 }
29862
29863
29864 6438 clear_bitmap(pricesdisplaybuf);
29865 6438 set_clip_state(pricesdisplaybuf, 1);
29866 }
29867
29868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
6985 if(itemsbuf[id2].family==itype_triforcepiece
29869
4/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 6911 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 60 times.
6978 && itemsbuf[id2].misc2 <= 0 && ptr->linked_parent == eeGANON)
29870 {
29871 7 game->lvlitems[dlevel]|=liBOSS;
29872 7 }
29873 6978 handle_triforce(id2);
29874
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 6500 times.
6978 if(!holdclk)
29875 6500 post_item_collect();
29876 6409328 }
29877
29878 186 void HeroClass::StartRefill(int32_t refillWhat)
29879 {
29880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186 times.
186 if(!refilling)
29881 {
29882 186 refillclk=21;
29883 186 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
29884 186 sfx(WAV_REFILL,128,true);
29885 186 refilling=refillWhat;
29886
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 6 times.
186 if(FFCore.quest_format[vZelda] < 0x255)
29887 {
29888 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
29889 //I attempted to change this check to a quest rule, but here's the issue: this affects
29890 //triforces and potions as well, not just fairy flags. This means that having a compat rule
29891 //would result in a rule that is checked by default for every tileset or quest made before
29892 //2.55, one in a place most people won't check. That means that if they were to go to use
29893 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
29894 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
29895 //"go through the compat rules and turn them all off", so this remains a version check instead
29896 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
29897 180 Start250Refill(refillWhat);
29898 180 }
29899 else //use 2.55+ behavior
29900 {
29901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(refill_why>=0) // Item index
29902 {
29903 if(itemsbuf[refill_why].family==itype_potion)
29904 {
29905 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
29906 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
29907 }
29908 else if(itemsbuf[refill_why].family==itype_triforcepiece)
29909 {
29910 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
29911 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
29912 }
29913 }
29914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(refill_why==REFILL_FAIRY)
29915 {
29916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
29917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_bit(quest_rules,qr_ITEMBUBBLE))itemclk=0;
29918 6 }
29919 }
29920 186 }
29921 186 }
29922
29923 180 void HeroClass::Start250Refill(int32_t refillWhat)
29924 {
29925
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!refilling)
29926 {
29927 refillclk=21;
29928 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
29929 sfx(WAV_REFILL,128,true);
29930 refilling=refillWhat;
29931
29932 if(refill_why>=0) // Item index
29933 {
29934 if((itemsbuf[refill_why].family==itype_potion)&&(!get_bit(quest_rules,qr_NONBUBBLEMEDICINE)))
29935 {
29936 swordclk=0;
29937 verifyAWpn();
29938 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
29939 }
29940
29941 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_bit(quest_rules,qr_NONBUBBLETRIFORCE)))
29942 {
29943 swordclk=0;
29944 verifyAWpn();
29945 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
29946 }
29947 }
29948 else if((refill_why==REFILL_FAIRY)&&(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)))
29949 {
29950 swordclk=0;
29951 verifyAWpn();
29952 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
29953 }
29954 }
29955 180 }
29956
29957 223990 bool HeroClass::refill()
29958 {
29959
4/4
✓ Branch 0 taken 17074 times.
✓ Branch 1 taken 206916 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 16438 times.
223990 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
29960 {
29961 207552 return false;
29962 }
29963
29964 16438 ++refillclk;
29965 16438 int32_t speed = get_bit(quest_rules,qr_FASTFILL) ? 6 : 22;
29966 16438 int32_t refill_heart_stop=game->get_maxlife();
29967 16438 int32_t refill_magic_stop=game->get_maxmagic();
29968
29969
4/4
✓ Branch 0 taken 8317 times.
✓ Branch 1 taken 8121 times.
✓ Branch 2 taken 3362 times.
✓ Branch 3 taken 4955 times.
16438 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
29970 {
29971
2/6
✓ Branch 0 taken 4955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4955 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4955 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
29972
2/6
✓ Branch 0 taken 4955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4955 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4955 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
29973 4955 }
29974
29975
2/2
✓ Branch 0 taken 14731 times.
✓ Branch 1 taken 1707 times.
16438 if(refillclk%speed == 0)
29976 {
29977 // game->life&=0xFFC;
29978
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 852 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 855 times.
1707 switch(refill_what)
29979 {
29980 case REFILL_LIFE:
29981
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 813 times.
852 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
29982
29983
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 749 times.
852 if(game->get_life()>=refill_heart_stop)
29984 {
29985 103 game->set_life(refill_heart_stop);
29986 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
29987
2/2
✓ Branch 0 taken 26368 times.
✓ Branch 1 taken 103 times.
26471 for ( int32_t q = 0; q < WAV_COUNT; q++ )
29988 {
29989
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 26265 times.
26368 if ( q == (int32_t)tmpscr->oceansfx ) continue;
29990
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26264 times.
26265 if ( q == (int32_t)tmpscr->bosssfx ) continue;
29991 26264 stop_sfx(q);
29992 26264 }
29993 103 sfx(QMisc.miscsfx[sfxREFILL]);
29994 103 refilling=REFILL_NONE;
29995 103 return false;
29996 }
29997
29998 749 break;
29999
30000 case REFILL_MAGIC:
30001 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
30002
30003 if(game->get_magic()>=refill_magic_stop)
30004 {
30005 game->set_magic(refill_magic_stop);
30006 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30007 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30008 {
30009 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30010 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30011 stop_sfx(q);
30012 }
30013 sfx(QMisc.miscsfx[sfxREFILL]);
30014 refilling=REFILL_NONE;
30015 return false;
30016 }
30017
30018 break;
30019
30020 case REFILL_ALL:
30021
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 788 times.
855 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
30022
2/2
✓ Branch 0 taken 825 times.
✓ Branch 1 taken 30 times.
855 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
30023
30024
4/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 753 times.
✓ Branch 2 taken 83 times.
✓ Branch 3 taken 19 times.
855 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
30025 {
30026 83 game->set_life(refill_heart_stop);
30027 83 game->set_magic(refill_magic_stop);
30028 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30029
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 83 times.
21331 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30030 {
30031
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 21165 times.
21248 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30032
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 21146 times.
21165 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30033 21146 stop_sfx(q);
30034 21146 }
30035 83 sfx(QMisc.miscsfx[sfxREFILL]);
30036 83 refilling=REFILL_NONE;
30037 83 return false;
30038 }
30039
30040 772 break;
30041 }
30042 1521 }
30043
30044 16252 return true;
30045 223990 }
30046
30047 60 void HeroClass::getTriforce(int32_t id2)
30048 {
30049
30050 PALETTE flash_pal;
30051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
30052
30053
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 60 times.
15420 for(int32_t i=0; i<256; i++)
30054 {
30055
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 7168 times.
15360 flash_pal[i] = get_bit(quest_rules,qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
30056 15360 }
30057
30058
30059
30060 //get rid off all sprites but Hero
30061 60 guys.clear();
30062 60 items.clear();
30063 60 Ewpns.clear();
30064 60 Lwpns.clear();
30065 60 Sitems.clear();
30066 60 chainlinks.clear();
30067
30068 //decorations.clear();
30069
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 17 times.
60 if(!COOLSCROLL)
30070 {
30071 17 show_subscreen_items=false;
30072 17 }
30073
30074 60 sfx(itemsbuf[id2].playsound);
30075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
30076
30077 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
30078
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
30079 {
30080 uint8_t playwav = itemsbuf[id2].misc3;
30081 //zprint2("playwav is: %d\n", playwav);
30082 sfx(playwav);
30083
30084 }
30085
30086 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
30087 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
30088 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
30089 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
30090 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
30091 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
30092 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
30093
30094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
30095 {
30096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(itemsbuf[id2].misc1)
30097 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
30098 else
30099 60 try_zcmusic((char*)moduledata.base_NSF_file,moduledata.tf_track, ZC_MIDI_TRIFORCE);
30100 60 }
30101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
30102 {
30103 60 game->lvlitems[dlevel]|=liTRIFORCE;
30104 60 }
30105
30106 60 int32_t f=0;
30107 60 int32_t x2=0;
30108 60 int32_t curtain_x=0;
30109 60 int32_t c=0;
30110 /*if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //Run collect script This happens w/o the flag.
30111 {
30112 if(itemsbuf[id2].collect_script && !item_collect_doscript[id2])
30113 {
30114 //clear the item script stack for a new script
30115 ri = &(itemCollectScriptData[id2]);
30116 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id2][q] = 0xFFFF;
30117 ri->Clear();
30118 //itemCollectScriptData[(id2 & 0xFFF)].Clear();
30119 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[(id2 & 0xFFF)][q] = 0;
30120 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2 & 0xFFF)*-1));
30121 if ( id2 > 0 && !item_collect_doscript[id2] ) //No collect script on item 0.
30122 {
30123 item_collect_doscript[id2] = 1;
30124 itemscriptInitialised[id2] = 0;
30125 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2)*-1));
30126 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
30127 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id2));
30128 }
30129 else if (!id2 && !item_collect_doscript[id2]) //item 0
30130 {
30131 item_collect_doscript[id2] = 1;
30132 itemscriptInitialised[id2] = 0;
30133 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
30134 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
30135 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
30136 }
30137 }
30138 }
30139 */
30140 60 do
30141 {
30142
30143
30144
1/2
✓ Branch 0 taken 32050 times.
✗ Branch 1 not taken.
32050 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
30145 {
30146 if ( itemsbuf[id2].script )
30147 {
30148 if ( !item_doscript[id2] )
30149 {
30150 ri = &(itemScriptData[id2]);
30151 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id2][q] = 0xFFFF;
30152 ri->Clear();
30153 item_doscript[id2] = 1;
30154 itemscriptInitialised[id2] = 0;
30155 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2);
30156 FFCore.deallocateAllArrays(SCRIPT_ITEM,(id2));
30157 }
30158 else
30159 {
30160 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
30161 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
30162 }
30163 }
30164 }
30165 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
30166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
30167 {
30168 return;
30169 }
30170
2/2
✓ Branch 0 taken 31990 times.
✓ Branch 1 taken 60 times.
32050 if(f==40)
30171 {
30172 60 actiontype oldaction = action;
30173 60 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
30174 60 action=oldaction; // have to reset this flag
30175 60 FFCore.setHeroAction(oldaction);
30176 60 }
30177
30178
30179
4/4
✓ Branch 0 taken 29650 times.
✓ Branch 1 taken 2400 times.
✓ Branch 2 taken 26770 times.
✓ Branch 3 taken 2880 times.
32050 if(f>=40 && f<88)
30180 {
30181
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 1344 times.
2880 if(get_bit(quest_rules,qr_FADE))
30182 {
30183
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1536 if (!flash_reduction_enabled() && (f&7) == 0)
30184 {
30185 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
30186 refreshpal=true;
30187 }
30188
30189
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 384 times.
1536 if((f&3)==2)
30190 {
30191 384 loadpalset(0,0);
30192 384 loadpalset(1,1);
30193 384 loadpalset(5,5);
30194
30195
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 12 times.
384 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
30196 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
30197 384 }
30198 1536 }
30199 else
30200 {
30201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1344 if(!flash_reduction_enabled() && (f&7) == 0)
30202 {
30203 for(int32_t cs2=2; cs2<5; cs2++)
30204 {
30205 for(int32_t i=1; i<16; i++)
30206 {
30207 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
30208 }
30209 }
30210
30211 refreshpal=true;
30212 }
30213
30214
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==4)
30215 {
30216
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
30217 else loadlvlpal(0xB);
30218
30219 168 loadpalset(5,5);
30220 168 }
30221 }
30222 2880 }
30223
30224
30225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
30226 {
30227
2/2
✓ Branch 0 taken 31990 times.
✓ Branch 1 taken 60 times.
32050 if(f==refill_frame)
30228 {
30229 60 refill_what=REFILL_ALL;
30230 60 refill_why=id2;
30231 60 StartRefill(REFILL_ALL);
30232 60 refill();
30233 60 }
30234
30235
2/2
✓ Branch 0 taken 28740 times.
✓ Branch 1 taken 3310 times.
32050 if(f==(refill_frame+1))
30236 {
30237
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 3250 times.
3310 if(refill())
30238 {
30239 3250 --f;
30240 3250 }
30241 3310 }
30242 32050 }
30243
30244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
30245 {
30246
4/4
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 15730 times.
✓ Branch 2 taken 11520 times.
✓ Branch 3 taken 4800 times.
32050 if(f>=208 && f<288)
30247 {
30248 4800 ++x2;
30249
30250
3/3
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 1920 times.
✓ Branch 2 taken 960 times.
4800 switch(++c)
30251 {
30252 case 5:
30253 960 c=0;
30254 [[fallthrough]];
30255 case 0:
30256 case 2:
30257 case 3:
30258 2880 ++x2;
30259 2880 break;
30260 }
30261 4800 }
30262
30263 32050 do_dcounters();
30264
30265
2/2
✓ Branch 0 taken 11520 times.
✓ Branch 1 taken 20530 times.
32050 if(f<288)
30266 {
30267 20530 curtain_x=x2&0xF8;
30268 20530 draw_screen_clip_rect_x1=curtain_x;
30269 20530 draw_screen_clip_rect_x2=255-curtain_x;
30270 20530 draw_screen_clip_rect_y1=0;
30271 20530 draw_screen_clip_rect_y2=223;
30272 //draw_screen(tmpscr);
30273 20530 }
30274 32050 }
30275
30276 32050 draw_screen(tmpscr);
30277 //this causes bugs
30278 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
30279 //so this is not necessary -DD
30280 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,false);
30281
30282 //Run Triforce Script
30283 32050 advanceframe(true);
30284 32050 ++f;
30285
2/2
✓ Branch 0 taken 31990 times.
✓ Branch 1 taken 60 times.
64100 }
30286 while
30287 (
30288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32050 times.
32050 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
30289
4/6
✓ Branch 0 taken 4380 times.
✓ Branch 1 taken 27670 times.
✓ Branch 2 taken 4380 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4380 times.
32050 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
30290
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4380 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4234 times.
✓ Branch 7 taken 146 times.
8760 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
30291 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
30292 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
30293 // value doesn't matter.
30294
2/4
✓ Branch 0 taken 4234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4380 times.
4380 || (replay_is_active() && f < 480) )
30295 ); // 800 may not be just right, but it works
30296
30297 60 action=none; FFCore.setHeroAction(none);
30298 60 holdclk=0;
30299 60 draw_screen_clip_rect_x1=0;
30300 60 draw_screen_clip_rect_x2=255;
30301 60 draw_screen_clip_rect_y1=0;
30302 60 draw_screen_clip_rect_y2=223;
30303 60 show_subscreen_items=true;
30304
30305 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
30306 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
30307
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 1 times.
60 if((itemsbuf[id2].flags & ITEM_FLAG1) && ( get_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
30308 {
30309 61 sdir=dir;
30310 61 dowarp(1,0); //side warp
30311 61 }
30312 else
30313 {
30314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
30315 }
30316 60 }
30317
30318 4662 void red_shift()
30319 {
30320 4662 int32_t tnum=176;
30321
30322 // set up the new palette
30323
2/2
✓ Branch 0 taken 149184 times.
✓ Branch 1 taken 4662 times.
153846 for(int32_t i=CSET(2); i < CSET(4); i++)
30324 {
30325 149184 int32_t r = (i-CSET(2)) << 1;
30326 149184 RAMpal[i+tnum].r = r;
30327 149184 RAMpal[i+tnum].g = r >> 3;
30328 149184 RAMpal[i+tnum].b = r >> 4;
30329 149184 }
30330
30331 // color scale the game screen
30332
2/2
✓ Branch 0 taken 783216 times.
✓ Branch 1 taken 4662 times.
787878 for(int32_t y=0; y<168; y++)
30333 {
30334
2/2
✓ Branch 0 taken 200503296 times.
✓ Branch 1 taken 783216 times.
201286512 for(int32_t x=0; x<256; x++)
30335 {
30336 200503296 int32_t c = framebuf->line[y+playing_field_offset][x];
30337
2/2
✓ Branch 0 taken 172617996 times.
✓ Branch 1 taken 27885300 times.
200503296 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30338
1/2
✓ Branch 0 taken 200503296 times.
✗ Branch 1 not taken.
200503296 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
30339 200503296 }
30340 783216 }
30341
30342 4662 refreshpal = true;
30343 4662 }
30344
30345
30346
30347 void setup_red_screen_old()
30348 {
30349 clear_bitmap(framebuf);
30350 rectfill(scrollbuf, 0, 0, 255, 167, 0);
30351
30352 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
30353
30354 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
30355
30356 putscr(scrollbuf, 0, 0, tmpscr);
30357 putscrdoors(scrollbuf,0,0,tmpscr);
30358 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30359 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
30360
30361 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
30362
30363 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
30364 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
30365 {
30366 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
30367 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
30368 }
30369
30370 if(!(msg_bg_display_buf->clip))
30371 {
30372 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30373 }
30374
30375 if(!(msg_portrait_display_buf->clip))
30376 {
30377 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30378 }
30379
30380 if(!(msg_txt_display_buf->clip))
30381 {
30382 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30383 }
30384
30385 if(!(pricesdisplaybuf->clip))
30386 {
30387 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
30388 }
30389
30390 //red shift
30391 // color scale the game screen
30392 for(int32_t y=0; y<168; y++)
30393 {
30394 for(int32_t x=0; x<256; x++)
30395 {
30396 int32_t c = framebuf->line[y+playing_field_offset][x];
30397 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30398 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
30399 }
30400 }
30401
30402 // Hero->draw(framebuf);
30403 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
30404
30405 clear_bitmap(framebuf);
30406
30407 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
30408 && tmpscr->layermap[3]==0
30409 && tmpscr->layermap[4]==0
30410 && tmpscr->layermap[5]==0
30411 && !overheadcombos(tmpscr)))
30412 {
30413 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
30414
30415 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
30416 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
30417 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
30418 {
30419 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
30420 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
30421 }
30422 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
30423 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
30424
30425 //do an AND masked blit for messages on top of layers
30426 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
30427 {
30428 BITMAP* subbmp = create_bitmap_ex(8,256,168);
30429 clear_bitmap(subbmp);
30430 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
30431 {
30432 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
30433 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
30434 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
30435 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
30436 }
30437 for(int32_t y=0; y<168; y++)
30438 {
30439 for(int32_t x=0; x<256; x++)
30440 {
30441 int32_t c1 = framebuf->line[y+playing_field_offset][x];
30442 int32_t c2 = subbmp->line[y][x];
30443 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
30444
30445 if(c1 && c3)
30446 {
30447 framebuf->line[y+playing_field_offset][x] = c3;
30448 }
30449 else if(c1 && c2)
30450 {
30451 framebuf->line[y+playing_field_offset][x] = c2;
30452 }
30453 }
30454 }
30455 destroy_bitmap(subbmp);
30456 }
30457
30458 //red shift
30459 // color scale the game screen
30460 for(int32_t y=0; y<168; y++)
30461 {
30462 for(int32_t x=0; x<256; x++)
30463 {
30464 int32_t c = framebuf->line[y+playing_field_offset][x];
30465 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30466 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
30467 }
30468 }
30469 }
30470
30471 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
30472
30473 // set up the new palette
30474 for(int32_t i=CSET(2); i < CSET(4); i++)
30475 {
30476 int32_t r = (i-CSET(2)) << 1;
30477 RAMpal[i].r = r;
30478 RAMpal[i].g = r >> 3;
30479 RAMpal[i].b = r >> 4;
30480 }
30481
30482 refreshpal = true;
30483 }
30484
30485
30486
30487 60 void slide_in_color(int32_t color)
30488 {
30489
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 60 times.
360 for(int32_t i=1; i<16; i+=3)
30490 {
30491 300 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
30492 300 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
30493 300 RAMpal[CSET(2)+i] = NESpal(color);
30494 300 }
30495
30496 60 refreshpal=true;
30497 60 }
30498
30499
30500 55 void HeroClass::heroDeathAnimation()
30501 {
30502 55 int32_t f=0;
30503 55 int32_t deathclk=0,deathfrm=0;
30504
30505 55 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
30506
30507 55 kill_sfx(); //call before the onDeath script.
30508
30509 //do
30510 //{
30511
30512 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
30513 // FFCore.Waitframe();
30514 //}while(player_doscript);
30515 //ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
30516 //while(player_doscript) { advanceframe(true); } //Not safe. The script runs for only one frame at present.
30517
30518 //Playing=false;
30519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(!debug_enabled)
30520 {
30521 55 Paused=false;
30522 55 }
30523
30524 /*
30525 game->set_deaths(zc_min(game->get_deaths()+1,999));
30526 dir=down;
30527 music_stop();
30528
30529 attackclk=hclk=superman=0;
30530 scriptcoldet = 1;
30531
30532 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
30533
30534
30535
30536 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
30537 quakeclk=wavy=0;
30538
30539 //in original Z1, Hero marker vanishes at death.
30540 //code in subscr.cpp, put_passive_subscr checks the following value.
30541 //color 255 is a GUI color, so quest makers shouldn't be using this value.
30542 //Also, subscreen is static after death in Z1.
30543 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
30544 QMisc.colors.hero_dot = 255;
30545 //doesn't work
30546 //scrollbuf is tampered with by draw_screen()
30547 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
30548 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
30549 clear_bitmap(subscrbmp);
30550 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, false, sspUP);
30551 QMisc.colors.hero_dot = tmp_hero_dot;
30552 */
30553 55 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
30554 55 clear_bitmap(subscrbmp);
30555 //get rid off all sprites but Hero
30556 55 guys.clear();
30557 55 items.clear();
30558 55 Ewpns.clear();
30559 55 Lwpns.clear();
30560 55 Sitems.clear();
30561 55 chainlinks.clear();
30562 55 decorations.clear();
30563 55 Playing = false;
30564
30565
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
30566 55 dir=down;
30567 55 music_stop();
30568
30569 55 attackclk=hclk=superman=0;
30570 55 scriptcoldet = 1;
30571
30572
2/2
✓ Branch 0 taken 1760 times.
✓ Branch 1 taken 55 times.
1815 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
30573
30574
30575
30576 55 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
30577 55 quakeclk=wavy=0;
30578
30579 //in original Z1, Hero marker vanishes at death.
30580 //code in subscr.cpp, put_passive_subscr checks the following value.
30581 //color 255 is a GUI color, so quest makers shouldn't be using this value.
30582 //Also, subscreen is static after death in Z1.
30583 55 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
30584 55 QMisc.colors.hero_dot = 255;
30585 //doesn't work
30586 //scrollbuf is tampered with by draw_screen()
30587 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
30588
30589 55 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
30590 //Don't forget passive subscreen scripts!
30591
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 2 times.
55 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
30592 {
30593 2 script_drawing_commands.Clear(); //We only want draws from this script
30594
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(DMaps[currdmap].passive_sub_script != 0)
30595 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
30596
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
30597 {
30598 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
30599 passive_subscreen_waitdraw = false;
30600 }
30601 2 BITMAP* tmp = framebuf;
30602 2 framebuf = subscrbmp; //Hack; force draws to subscrbmp
30603 2 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
30604 2 framebuf = tmp;
30605 2 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
30606 2 }
30607 55 QMisc.colors.hero_dot = tmp_hero_dot;
30608 55 bool clearedit = false;
30609 55 do
30610 {
30611
2/2
✓ Branch 0 taken 13767 times.
✓ Branch 1 taken 5346 times.
19113 if(f<254)
30612 {
30613
2/2
✓ Branch 0 taken 11952 times.
✓ Branch 1 taken 1815 times.
13767 if(f<=32)
30614 {
30615 1815 hclk=(32-f);
30616 1815 }
30617
30618
4/4
✓ Branch 0 taken 10369 times.
✓ Branch 1 taken 3398 times.
✓ Branch 2 taken 6265 times.
✓ Branch 3 taken 4104 times.
13767 if(f>=62 && f<138)
30619 {
30620
5/5
✓ Branch 0 taken 3240 times.
✓ Branch 1 taken 216 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 216 times.
4104 switch((f-62)%20)
30621 {
30622 case 0:
30623 216 dir=right;
30624 216 break;
30625
30626 case 5:
30627 216 dir=up;
30628 216 break;
30629
30630 case 10:
30631 216 dir=left;
30632 216 break;
30633
30634 case 15:
30635 216 dir=down;
30636 216 break;
30637 }
30638
30639 4104 herostep();
30640 4104 }
30641
30642
4/4
✓ Branch 0 taken 3241 times.
✓ Branch 1 taken 10526 times.
✓ Branch 2 taken 2483 times.
✓ Branch 3 taken 758 times.
13767 if(f>=194 && f<208)
30643 {
30644
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 54 times.
758 if(f==194)
30645 {
30646 54 action=dying;
30647 54 FFCore.setHeroAction(dying);
30648 54 }
30649
30650 758 extend = 0;
30651 758 cs = wpnsbuf[spr_death].csets&15;
30652 758 tile = wpnsbuf[spr_death].tile;
30653
2/2
✓ Branch 0 taken 742 times.
✓ Branch 1 taken 16 times.
758 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
30654 {
30655 16 tile += deathfrm;
30656 16 f = 206;
30657
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(++deathclk >= wpnsbuf[spr_death].speed)
30658 {
30659 4 deathclk=0;
30660
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 if(++deathfrm >= wpnsbuf[spr_death].frames)
30661 {
30662 1 f = 208;
30663 1 deathfrm = 0;
30664 1 }
30665 4 }
30666 16 }
30667
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 392 times.
742 else if(BSZ)
30668 {
30669 350 tile += (f-194)/3;
30670 350 }
30671
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 112 times.
392 else if(f>=204)
30672 {
30673 112 ++tile;
30674 112 }
30675 758 }
30676
30677
2/2
✓ Branch 0 taken 13713 times.
✓ Branch 1 taken 54 times.
13767 if(f==208)
30678 {
30679
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 51 times.
54 if ( dontdraw < 2 ) { dontdraw = 1; }
30680 54 }
30681
2/2
✓ Branch 0 taken 10719 times.
✓ Branch 1 taken 3048 times.
13767 if(get_bit(quest_rules,qr_FADE))
30682 {
30683
2/2
✓ Branch 0 taken 7190 times.
✓ Branch 1 taken 3529 times.
10719 if(f < 170)
30684 {
30685
2/2
✓ Branch 0 taken 4620 times.
✓ Branch 1 taken 2570 times.
7190 if(f<60)
30686 {
30687 2570 draw_screen(tmpscr);
30688 //reuse our static subscreen
30689 2570 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
30690 2570 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30691 2570 }
30692
30693
2/2
✓ Branch 0 taken 7148 times.
✓ Branch 1 taken 42 times.
7190 if(f==60)
30694 {
30695 42 red_shift();
30696 42 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
30697 42 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
30698 42 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
30699
30700
2/2
✓ Branch 0 taken 10752 times.
✓ Branch 1 taken 42 times.
10794 for(int32_t q=0; q<PAL_SIZE; q++)
30701 {
30702 10752 trans_table2.data[0][q] = q;
30703 10752 trans_table2.data[q][q] = q;
30704 10752 }
30705 42 }
30706
30707
3/4
✓ Branch 0 taken 4620 times.
✓ Branch 1 taken 2570 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4620 times.
7190 if(f>=60 && f<=169)
30708 {
30709 4620 draw_screen(tmpscr);
30710 //reuse our static subscreen
30711 4620 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30712 4620 red_shift();
30713
30714 4620 }
30715
30716
3/4
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 5888 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1302 times.
7190 if(f>=139 && f<=169)//fade from red to black
30717 {
30718 1302 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
30719 1302 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
30720 1302 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
30721 1302 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
30722
30723
2/2
✓ Branch 0 taken 333312 times.
✓ Branch 1 taken 1302 times.
334614 for(int32_t q=0; q<PAL_SIZE; q++)
30724 {
30725 333312 trans_table2.data[0][q] = q;
30726 333312 trans_table2.data[q][q] = q;
30727 333312 }
30728
30729 1302 refreshpal=true;
30730 1302 }
30731 7190 }
30732 else //f>=170
30733 {
30734
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 42 times.
3529 if(f==170)//make Hero grayish
30735 {
30736 42 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
30737
30738
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 42 times.
714 for(int32_t i=CSET(6); i < CSET(7); i++)
30739 {
30740 672 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
30741 672 RAMpal[i] = _RGB(g,g,g);
30742 672 }
30743
30744 42 refreshpal = true;
30745 42 }
30746
30747 //draw only hero. otherwise black layers might cover him.
30748 3529 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
30749 3529 draw(framebuf);
30750 3529 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30751 }
30752 10719 }
30753 else //!qr_FADE
30754 {
30755
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==58)
30756 {
30757
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 12 times.
1164 for(int32_t i = 0; i < 96; i++)
30758 1152 tmpscr->cset[i] = 3;
30759
30760
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30761
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
30762
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
30763 194 tmpscr2[j].cset[i] = 3;
30764 12 }
30765
30766
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==59)
30767 {
30768
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 12 times.
972 for(int32_t i = 96; i < 176; i++)
30769 960 tmpscr->cset[i] = 3;
30770
30771
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30772
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
30773
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
30774 162 tmpscr2[j].cset[i] = 3;
30775 12 }
30776
30777
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==60)
30778 {
30779
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 for(int32_t i=0; i<176; i++)
30780 {
30781 2112 tmpscr->cset[i] = 2;
30782 2112 }
30783
30784
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30785
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
30786
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
30787 354 tmpscr2[j].cset[i] = 2;
30788
30789
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
30790 {
30791 60 RAMpal[CSET(2)+i] = NESpal(0x17);
30792 60 RAMpal[CSET(2)+i+1] = NESpal(0x16);
30793 60 RAMpal[CSET(2)+i+2] = NESpal(0x26);
30794 60 }
30795
30796 12 refreshpal=true;
30797 12 }
30798
30799
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==139)
30800 12 slide_in_color(0x06);
30801
30802
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==149)
30803 12 slide_in_color(0x07);
30804
30805
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==159)
30806 12 slide_in_color(0x0F);
30807
30808
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==169)
30809 {
30810 12 slide_in_color(0x0F);
30811 12 slide_in_color(0x0F);
30812 12 }
30813
30814
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==170)
30815 {
30816
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
30817 {
30818 60 RAMpal[CSET(6)+i] = NESpal(0x10);
30819 60 RAMpal[CSET(6)+i+1] = NESpal(0x30);
30820 60 RAMpal[CSET(6)+i+2] = NESpal(0x00);
30821 60 refreshpal = true;
30822 60 }
30823 12 }
30824
30825
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 1020 times.
3048 if(f < 169)
30826 {
30827 2028 draw_screen(tmpscr);
30828 //reuse our static subscreen
30829 2028 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30830 2028 }
30831 else
30832 {
30833 //draw only hero. otherwise black layers might cover him.
30834 1020 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
30835 1020 draw(framebuf);
30836 1020 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30837 }
30838 }
30839 13767 }
30840
30841
2/2
✓ Branch 0 taken 5184 times.
✓ Branch 1 taken 162 times.
5346 else if(f<350)//draw 'GAME OVER' text
30842 {
30843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5184 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5184 if(get_bit(quest_rules, qr_INSTANT_RESPAWN) && !get_bit(quest_rules, qr_INSTANT_CONTINUE))
30844 {
30845 Quit = qRELOAD;
30846 skipcont = 1;
30847 clear_bitmap(framebuf);
30848 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30849 }
30850
2/4
✓ Branch 0 taken 5184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5184 times.
5184 else if(!get_bit(quest_rules, qr_INSTANT_RESPAWN) && get_bit(quest_rules, qr_INSTANT_CONTINUE))
30851 {
30852 Quit = qCONT;
30853 skipcont = 1;
30854 clear_bitmap(framebuf);
30855 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30856 }
30857 else
30858 {
30859 5184 clear_a5_bmp(rti_infolayer.bitmap);
30860 5184 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
30861 5184 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30862 5184 textout_ex(framebuf,get_zc_font(font_zfont),"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
30863 }
30864 5184 }
30865 else
30866 {
30867 162 clear_bitmap(framebuf);
30868 }
30869
30870 //SFX... put them all here
30871
4/4
✓ Branch 0 taken 18951 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 53 times.
19113 switch(f)
30872 {
30873 case 0:
30874 55 sfx(getHurtSFX(),pan(x.getInt()));
30875 55 break;
30876 //Death sound.
30877 case 60:
30878 54 sfx(WAV_SPIRAL);
30879 54 break;
30880 //Message sound.
30881 case 194:
30882 53 sfx(WAV_MSG);
30883 53 break;
30884 }
30885 //adv:
30886 19113 advanceframe(true);
30887 19113 ++f;
30888 //if (!player_doscript ) ++f;
30889
2/2
✓ Branch 0 taken 19058 times.
✓ Branch 1 taken 55 times.
38226 }
30890
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 19059 times.
19113 while(f<353 && !Quit);
30891
30892 55 destroy_bitmap(subscrbmp);
30893 55 action=none; FFCore.setHeroAction(none);
30894
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 52 times.
55 if ( dontdraw < 2 ) { dontdraw=0; }
30895 55 }
30896
30897
30898 13 void HeroClass::ganon_intro()
30899 {
30900 /*
30901 ************************
30902 * GANON INTRO SEQUENCE *
30903 ************************
30904 -25 DOT updates
30905 -24 HERO in
30906 0 TRIFORCE overhead - code begins at this point (f == 0)
30907 47 GANON in
30908 58 LIGHT step
30909 68 LIGHT step
30910 78 LIGHT step
30911 255 TRIFORCE out
30912 256 TRIFORCE in
30913 270 TRIFORCE out
30914 271 GANON out, HERO face up
30915 */
30916 13 loaded_guys=true;
30917 13 loaditem();
30918
30919
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 9 times.
13 if(game->lvlitems[dlevel]&liBOSS)
30920 {
30921 4 return;
30922 }
30923
30924 9 dir=down;
30925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if ( !isSideViewHero() )
30926 {
30927 9 fall = 0; //Fix midair glitch on holding triforce. -Z
30928 9 fakefall = 0;
30929 9 z = 0;
30930 9 fakez = 0;
30931 9 }
30932 9 action=landhold2; FFCore.setHeroAction(landhold2);
30933 9 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
30934 //not good, as this only returns the highest level that Hero possesses. -DD
30935 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
30936
30937
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2169 times.
✓ Branch 2 taken 2169 times.
✓ Branch 3 taken 9 times.
2178 for(int32_t f=0; f<271 && !Quit; f++)
30938 {
30939
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
2169 if(f==47)
30940 {
30941 9 music_stop();
30942 9 stop_sfx(WAV_ROAR);
30943 9 sfx(WAV_GASP);
30944 9 sfx(WAV_GANON);
30945 9 int32_t Id=0;
30946
30947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 711 times.
711 for(int32_t i=0; i<eMAXGUYS; i++)
30948 {
30949
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 9 times.
711 if(guysbuf[i].flags2&eneflag_ganon)
30950 {
30951 9 Id=i;
30952 9 break;
30953 }
30954 702 }
30955
30956
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if(current_item(itype_ring))
30957 {
30958 8 addenemy(160,96,Id,0);
30959 8 }
30960 else
30961 {
30962 1 addenemy(80,32,Id,0);
30963 }
30964 9 }
30965
30966
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
2169 if(f==48)
30967 {
30968 9 lighting(true,true); // Hmm. -L
30969 9 f += 30;
30970 9 }
30971
30972 //NES Z1, the triforce vanishes for one frame in two cases
30973 //while still showing Hero's two-handed overhead sprite.
30974 //This should be a Quest Rule for NES Accuracy. -Z
30975
4/4
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2151 times.
2169 if(f==255 || f==270)
30976 {
30977 18 holditem=-1;
30978 18 }
30979
30980
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 9 times.
2169 if(f==256)
30981 {
30982 9 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
30983 9 }
30984
30985 2169 draw_screen(tmpscr);
30986 2169 advanceframe(true);
30987
30988
1/2
✓ Branch 0 taken 2169 times.
✗ Branch 1 not taken.
2169 if(rSbtn())
30989 {
30990 conveyclk=3;
30991 int32_t tmp_subscr_clk = frame;
30992 dosubscr(&QMisc);
30993 newscr_clk += frame - tmp_subscr_clk;
30994 }
30995
30996 2169 }
30997
30998 9 action=none; FFCore.setHeroAction(none);
30999 9 dir=up;
31000
31001
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 7 times.
9 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
31002 2 jukebox(MAXMIDIS-1);
31003 else
31004 7 playLevelMusic();
31005
31006 9 currcset=DMaps[currdmap].color;
31007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (get_bit(quest_rules, qr_GANONINTRO) )
31008 {
31009 9 dointro();
31010 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
31011 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
31012 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
31013 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
31014 9 }
31015 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
31016 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
31017 //on a different DMap.
31018 //~ Otherwise, why is it here?! -Z
31019
31020
31021 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
31022 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
31023
31024 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
31025 //Users who use that dmap rule should put ganons room on its own DMap! -Z
31026 9 cont_sfx(WAV_ROAR);
31027 13 }
31028
31029 9 void HeroClass::win_game()
31030 {
31031
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 replay_step_comment("win_game");
31032 9 Playing=Paused=false;
31033 9 action=won; FFCore.setHeroAction(won);
31034 9 Quit=qWON;
31035 9 hclk=0;
31036 9 x = 136;
31037
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 y = (isdungeon() && currscr<128) ? 75 : 73;
31038 9 z = fakez = fall = fakefall = spins = 0;
31039 9 dir=left;
31040 9 }
31041
31042 14984 void HeroClass::reset_swordcharge()
31043 {
31044 14984 charging=spins=tapping=0;
31045 14984 }
31046
31047 47175 void HeroClass::reset_hookshot()
31048 {
31049
10/12
✓ Branch 0 taken 35602 times.
✓ Branch 1 taken 11573 times.
✓ Branch 2 taken 35595 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 35549 times.
✓ Branch 5 taken 46 times.
✓ Branch 6 taken 35544 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 35544 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 35544 times.
47175 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
31050 {
31051 35544 action=none; FFCore.setHeroAction(none);
31052 35544 }
31053
31054 47175 hookshot_frozen=false;
31055 47175 hookshot_used=false;
31056 47175 pull_hero=false;
31057 47175 hs_fix=false;
31058 47175 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
31059 47175 switch_hooked = false;
31060
2/2
✓ Branch 0 taken 47174 times.
✓ Branch 1 taken 1 times.
47175 if(switching_object)
31061 1 switching_object->switch_hooked = false;
31062 47175 switching_object = NULL;
31063 47175 hooked_combopos = -1;
31064 47175 switchhook_cost_item = -1;
31065 47175 hooked_layerbits = 0;
31066
2/2
✓ Branch 0 taken 330225 times.
✓ Branch 1 taken 47175 times.
377400 for(auto q = 0; q < 7; ++q)
31067 330225 hooked_undercombos[q] = -1;
31068 47175 Lwpns.del(Lwpns.idFirst(wHSHandle));
31069 47175 Lwpns.del(Lwpns.idFirst(wHookshot));
31070 47175 chainlinks.clear();
31071
2/2
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 44701 times.
47175 int32_t index=directItem>-1 ? directItem : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
31072 47175 hs_switcher = false;
31073
31074
2/2
✓ Branch 0 taken 39666 times.
✓ Branch 1 taken 7509 times.
47175 if(index>=0)
31075 {
31076 7509 stop_sfx(itemsbuf[index].usesound);
31077 7509 }
31078
31079 47175 hs_xdist=0;
31080 47175 hs_ydist=0;
31081 47175 }
31082
31083
31084 4377848 bool HeroClass::can_deploy_ladder()
31085 {
31086
2/2
✓ Branch 0 taken 1612499 times.
✓ Branch 1 taken 2765349 times.
6732950 bool ladderallowed = ((!get_bit(quest_rules,qr_LADDERANYWHERE) && tmpscr->flags&fLADDER) || isdungeon()
31087
4/4
✓ Branch 0 taken 1402943 times.
✓ Branch 1 taken 2355102 times.
✓ Branch 2 taken 545441 times.
✓ Branch 3 taken 1809661 times.
2765349 || (get_bit(quest_rules,qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
31088
8/10
✓ Branch 0 taken 1715915 times.
✓ Branch 1 taken 3654629 times.
✓ Branch 2 taken 1345466 times.
✓ Branch 3 taken 370449 times.
✓ Branch 4 taken 1345397 times.
✓ Branch 5 taken 69 times.
✓ Branch 6 taken 1345397 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1345397 times.
6715941 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
31089
2/2
✓ Branch 0 taken 1324717 times.
✓ Branch 1 taken 20680 times.
1345397 (!isSideViewHero() || on_sideview_solid_oldpos(x,y,old_x,old_y)));
31090 }
31091
31092 5602640 void HeroClass::reset_ladder()
31093 {
31094 5602640 ladderx=laddery=0;
31095 5602640 }
31096
31097 bool is_conveyor(int32_t type);
31098 int32_t get_conveyor(int32_t x, int32_t y);
31099
31100 6418199 void HeroClass::check_conveyor()
31101 {
31102 6418199 ++newconveyorclk;
31103
1/2
✓ Branch 0 taken 6418199 times.
✗ Branch 1 not taken.
6418199 if (newconveyorclk < 0) newconveyorclk = 0;
31104
31105
14/18
✓ Branch 0 taken 6418199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6418199 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6417559 times.
✓ Branch 5 taken 640 times.
✓ Branch 6 taken 6417559 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6417559 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6414984 times.
✓ Branch 11 taken 2575 times.
✓ Branch 12 taken 6414362 times.
✓ Branch 13 taken 622 times.
✓ Branch 14 taken 6410729 times.
✓ Branch 15 taken 3633 times.
✓ Branch 16 taken 6410729 times.
✓ Branch 17 taken 3633 times.
6418199 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
31106 {
31107 7470 is_conveyor_stunned = 0;
31108 7470 return;
31109 }
31110
31111 6410729 WalkflagInfo info;
31112 int32_t xoff,yoff;
31113 6410729 zfix deltax(0), deltay(0);
31114 6410729 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
31115
2/2
✓ Branch 0 taken 2132640 times.
✓ Branch 1 taken 4278089 times.
6410729 if(cmbid < 0)
31116 {
31117
2/2
✓ Branch 0 taken 4277378 times.
✓ Branch 1 taken 711 times.
4278089 if (conveyclk <= 0) is_on_conveyor=false;
31118 4278089 return;
31119 }
31120 2132640 newcombo const* cmb = &combobuf[cmbid];
31121 2132640 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
31122 2132640 bool custom_spd = (cmb->usrflags&cflag2);
31123
3/4
✓ Branch 0 taken 2131865 times.
✓ Branch 1 taken 775 times.
✓ Branch 2 taken 2131865 times.
✗ Branch 3 not taken.
2132640 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
31124 {
31125 2132640 int32_t ctype=cmb->type;
31126
3/4
✓ Branch 0 taken 775 times.
✓ Branch 1 taken 2131865 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 775 times.
2132640 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
31127
3/4
✓ Branch 0 taken 775 times.
✓ Branch 1 taken 2131865 times.
✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
2132640 if(custom_spd && (newconveyorclk % rate)) return;
31128
3/4
✓ Branch 0 taken 555 times.
✓ Branch 1 taken 2132085 times.
✓ Branch 2 taken 555 times.
✗ Branch 3 not taken.
2132640 if((cmb->usrflags&cflag5) && HasHeavyBoots())
31129 return;
31130 2132640 is_on_conveyor=false;
31131 2132640 is_conveyor_stunned=0;
31132
31133 2132640 deltax=combo_class_buf[ctype].conveyor_x_speed;
31134 2132640 deltay=combo_class_buf[ctype].conveyor_y_speed;
31135
31136
3/4
✓ Branch 0 taken 1735 times.
✓ Branch 1 taken 2130905 times.
✓ Branch 2 taken 1735 times.
✗ Branch 3 not taken.
2132640 if (is_conveyor(ctype) && custom_spd)
31137 {
31138 deltax = zslongToFix(cmb->attributes[0]);
31139 deltay = zslongToFix(cmb->attributes[1]);
31140 }
31141
31142
8/8
✓ Branch 0 taken 2131855 times.
✓ Branch 1 taken 785 times.
✓ Branch 2 taken 2130905 times.
✓ Branch 3 taken 950 times.
✓ Branch 4 taken 87444 times.
✓ Branch 5 taken 2043461 times.
✓ Branch 6 taken 42801 times.
✓ Branch 7 taken 44643 times.
2132640 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(x,y,old_x,old_y)))
31143 {
31144 44643 cmbid = MAPCOMBO(x+8,y+16);
31145 44643 cmb = &combobuf[cmbid];
31146 44643 custom_spd = cmb->usrflags&cflag2;
31147 44643 ctype=(cmb->type);
31148
3/4
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 43835 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 808 times.
44643 rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
31149 44643 deltax=combo_class_buf[ctype].conveyor_x_speed;
31150 44643 deltay=combo_class_buf[ctype].conveyor_y_speed;
31151
2/4
✓ Branch 0 taken 44643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44643 times.
✗ Branch 3 not taken.
44643 if ((deltax != 0 || deltay != 0) && custom_spd)
31152 {
31153 deltax = zslongToFix(cmb->attributes[0]);
31154 deltay = zslongToFix(cmb->attributes[1]);
31155 }
31156 44643 }
31157
31158
4/4
✓ Branch 0 taken 2131855 times.
✓ Branch 1 taken 785 times.
✓ Branch 2 taken 950 times.
✓ Branch 3 taken 2130905 times.
2132640 if(deltax!=0||deltay!=0)
31159 {
31160 1735 is_on_conveyor=true;
31161 1735 }
31162 2130905 else return;
31163
31164
1/2
✓ Branch 0 taken 1735 times.
✗ Branch 1 not taken.
1735 bool forcewalk = (cmb->usrflags&cflag6) && get_bit(quest_rules,qr_NEW_HERO_MOVEMENT2);
31165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1735 times.
1735 if(forcewalk)
31166 {
31167 is_conveyor_stunned = rate;
31168 if(cmb->usrflags&cflag3)
31169 {
31170 if(abs(deltax) > abs(deltay))
31171 dir = (deltax > 0) ? right : left;
31172 else dir = (deltay > 0) ? down : up;
31173 }
31174 convey_forcex = deltax;
31175 convey_forcey = deltay;
31176 }
31177 else
31178 {
31179 1735 bool movedx = false, movedy = false;
31180
1/2
✓ Branch 0 taken 1735 times.
✗ Branch 1 not taken.
1735 if(cmb->usrflags&cflag4) //Smart corners
31181 {
31182 if(deltay<0)
31183 {
31184 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
31185 execute(info);
31186
31187 if(!info.isUnwalkable())
31188 {
31189 movedy = true;
31190 zfix step(0);
31191
31192 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31193 {
31194 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
31195 {
31196 yoff=int32_t(y-step)&7;
31197
31198 if(!yoff) break;
31199
31200 step++;
31201 }
31202 }
31203 else
31204 {
31205 step=abs(deltay);
31206 }
31207
31208 y=y-step;
31209 hs_starty-=step.getInt();
31210
31211 for(int32_t j=0; j<chainlinks.Count(); j++)
31212 {
31213 chainlinks.spr(j)->y-=step;
31214 }
31215
31216 if(Lwpns.idFirst(wHookshot)>-1)
31217 {
31218 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
31219 }
31220
31221 if(Lwpns.idFirst(wHSHandle)>-1)
31222 {
31223 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
31224 }
31225 }
31226 }
31227 else if(deltay>0)
31228 {
31229 info = walkflag(x,y+15+2,2,down);
31230 execute(info);
31231
31232 if(!info.isUnwalkable())
31233 {
31234 movedy = true;
31235 zfix step(0);
31236
31237 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31238 {
31239 while(step<abs(deltay))
31240 {
31241 yoff=int32_t(y+step)&7;
31242
31243 if(!yoff) break;
31244
31245 step++;
31246 }
31247 }
31248 else
31249 {
31250 step=abs(deltay);
31251 }
31252
31253 y=y+step;
31254 hs_starty+=step.getInt();
31255
31256 for(int32_t j=0; j<chainlinks.Count(); j++)
31257 {
31258 chainlinks.spr(j)->y+=step;
31259 }
31260
31261 if(Lwpns.idFirst(wHookshot)>-1)
31262 {
31263 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
31264 }
31265
31266 if(Lwpns.idFirst(wHSHandle)>-1)
31267 {
31268 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
31269 }
31270 }
31271 }
31272
31273 if(deltax<0)
31274 {
31275 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
31276 execute(info);
31277
31278 if(!info.isUnwalkable())
31279 {
31280 movedx = true;
31281 zfix step(0);
31282
31283 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31284 {
31285 while(step<abs(deltax))
31286 {
31287 xoff=int32_t(x-step)&7;
31288
31289 if(!xoff) break;
31290
31291 step++;
31292 }
31293 }
31294 else
31295 {
31296 step=abs(deltax);
31297 }
31298
31299 x=x-step;
31300 hs_startx-=step.getInt();
31301
31302 for(int32_t j=0; j<chainlinks.Count(); j++)
31303 {
31304 chainlinks.spr(j)->x-=step;
31305 }
31306
31307 if(Lwpns.idFirst(wHookshot)>-1)
31308 {
31309 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
31310 }
31311
31312 if(Lwpns.idFirst(wHSHandle)>-1)
31313 {
31314 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
31315 }
31316 }
31317 }
31318 else if(deltax>0)
31319 {
31320 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
31321 execute(info);
31322
31323 if(!info.isUnwalkable())
31324 {
31325 movedx = true;
31326 zfix step(0);
31327
31328 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31329 {
31330 while(step<abs(deltax))
31331 {
31332 xoff=int32_t(x+step)&7;
31333
31334 if(!xoff) break;
31335
31336 step++;
31337 }
31338 }
31339 else
31340 {
31341 step=abs(deltax);
31342 }
31343
31344 x=x+step;
31345 hs_startx+=step.getInt();
31346
31347 for(int32_t j=0; j<chainlinks.Count(); j++)
31348 {
31349 chainlinks.spr(j)->x+=step;
31350 }
31351
31352 if(Lwpns.idFirst(wHookshot)>-1)
31353 {
31354 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
31355 }
31356
31357 if(Lwpns.idFirst(wHSHandle)>-1)
31358 {
31359 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
31360 }
31361 }
31362 }
31363 if(deltax && !movedx)
31364 y = COMBOY(pos);
31365 if(deltay && !movedy)
31366 x = COMBOX(pos);
31367 }
31368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1735 times.
1735 if(!movedy)
31369 {
31370
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 1525 times.
1735 if(deltay<0)
31371 {
31372 210 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
31373 210 execute(info);
31374
31375
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 184 times.
210 if(!info.isUnwalkable())
31376 {
31377 184 movedy = true;
31378 184 zfix step(0);
31379
31380
10/12
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 118 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 55 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 6 times.
184 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31381 {
31382
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 11 times.
16 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
31383 {
31384 11 yoff=int32_t(y-step)&7;
31385
31386
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if(!yoff) break;
31387
31388 10 step++;
31389 }
31390 6 }
31391 else
31392 {
31393 178 step=abs(deltay);
31394 }
31395
31396 184 y=y-step;
31397 184 hs_starty-=step.getInt();
31398
31399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 184 times.
184 for(int32_t j=0; j<chainlinks.Count(); j++)
31400 {
31401 chainlinks.spr(j)->y-=step;
31402 }
31403
31404
1/2
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
184 if(Lwpns.idFirst(wHookshot)>-1)
31405 {
31406 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
31407 }
31408
31409
1/2
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
184 if(Lwpns.idFirst(wHSHandle)>-1)
31410 {
31411 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
31412 }
31413 184 }
31414 26 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
31415 210 }
31416
2/2
✓ Branch 0 taken 785 times.
✓ Branch 1 taken 740 times.
1525 else if(deltay>0)
31417 {
31418 740 info = walkflag(x,y+15+2,2,down);
31419 740 execute(info);
31420
31421
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 488 times.
740 if(!info.isUnwalkable())
31422 {
31423 488 movedy = true;
31424 488 zfix step(0);
31425
31426
9/12
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 167 times.
✓ Branch 3 taken 321 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 62 times.
488 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31427 {
31428
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 104 times.
144 while(step<abs(deltay))
31429 {
31430 104 yoff=int32_t(y+step)&7;
31431
31432
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 82 times.
104 if(!yoff) break;
31433
31434 82 step++;
31435 }
31436 62 }
31437 else
31438 {
31439 426 step=abs(deltay);
31440 }
31441
31442 488 y=y+step;
31443 488 hs_starty+=step.getInt();
31444
31445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 488 times.
488 for(int32_t j=0; j<chainlinks.Count(); j++)
31446 {
31447 chainlinks.spr(j)->y+=step;
31448 }
31449
31450
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(Lwpns.idFirst(wHookshot)>-1)
31451 {
31452 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
31453 }
31454
31455
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(Lwpns.idFirst(wHSHandle)>-1)
31456 {
31457 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
31458 }
31459 488 }
31460 252 else checkdamagecombos(x,y+15);
31461 740 }
31462 1735 }
31463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1735 times.
1735 if(!movedx)
31464 {
31465
2/2
✓ Branch 0 taken 518 times.
✓ Branch 1 taken 1217 times.
1735 if(deltax<0)
31466 {
31467 518 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
31468 518 execute(info);
31469
31470
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 352 times.
518 if(!info.isUnwalkable())
31471 {
31472 352 movedx = true;
31473 352 zfix step(0);
31474
31475
9/12
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 296 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 38 times.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 18 times.
352 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31476 {
31477
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 while(step<abs(deltax))
31478 {
31479 32 xoff=int32_t(x-step)&7;
31480
31481
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 5 times.
32 if(!xoff) break;
31482
31483 27 step++;
31484 }
31485 18 }
31486 else
31487 {
31488 334 step=abs(deltax);
31489 }
31490
31491 352 x=x-step;
31492 352 hs_startx-=step.getInt();
31493
31494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 352 times.
352 for(int32_t j=0; j<chainlinks.Count(); j++)
31495 {
31496 chainlinks.spr(j)->x-=step;
31497 }
31498
31499
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(Lwpns.idFirst(wHookshot)>-1)
31500 {
31501 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
31502 }
31503
31504
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(Lwpns.idFirst(wHSHandle)>-1)
31505 {
31506 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
31507 }
31508 352 }
31509 166 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
31510 518 }
31511
2/2
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 267 times.
1217 else if(deltax>0)
31512 {
31513 267 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
31514 267 execute(info);
31515
31516
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 264 times.
267 if(!info.isUnwalkable())
31517 {
31518 264 movedx = true;
31519 264 zfix step(0);
31520
31521
9/12
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 208 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 25 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 25 times.
264 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31522 {
31523
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 47 times.
67 while(step<abs(deltax))
31524 {
31525 47 xoff=int32_t(x+step)&7;
31526
31527
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5 times.
47 if(!xoff) break;
31528
31529 42 step++;
31530 }
31531 25 }
31532 else
31533 {
31534 239 step=abs(deltax);
31535 }
31536
31537 264 x=x+step;
31538 264 hs_startx+=step.getInt();
31539
31540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 for(int32_t j=0; j<chainlinks.Count(); j++)
31541 {
31542 chainlinks.spr(j)->x+=step;
31543 }
31544
31545
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(Lwpns.idFirst(wHookshot)>-1)
31546 {
31547 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
31548 }
31549
31550
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(Lwpns.idFirst(wHSHandle)>-1)
31551 {
31552 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
31553 }
31554 264 }
31555 3 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
31556 267 }
31557 1735 }
31558
4/4
✓ Branch 0 taken 1119 times.
✓ Branch 1 taken 616 times.
✓ Branch 2 taken 672 times.
✓ Branch 3 taken 447 times.
1735 if(movedx || movedy)
31559 {
31560
1/2
✓ Branch 0 taken 1288 times.
✗ Branch 1 not taken.
1288 if(cmb->usrflags&cflag1)
31561 is_conveyor_stunned = rate;
31562
1/2
✓ Branch 0 taken 1288 times.
✗ Branch 1 not taken.
1288 if(cmb->usrflags&cflag3)
31563 {
31564 if(abs(deltax) > abs(deltay))
31565 dir = (deltax > 0) ? right : left;
31566 else dir = (deltay > 0) ? down : up;
31567 }
31568 1288 }
31569 }
31570 1735 }
31571 6418199 }
31572
31573 void HeroClass::setDivineProtectionShieldClk(int32_t newclk)
31574 {
31575 DivineProtectionShieldClk=newclk;
31576
31577 if(decorations.idCount(dDIVINEPROTECTIONSHIELD)==0)
31578 {
31579 decoration *dec;
31580 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
31581 decorations.spr(decorations.Count()-1)->misc=0;
31582 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
31583 dec=(decoration *)decorations.spr(decorations.Count()-1);
31584 decorations.spr(decorations.Count()-1)->misc=1;
31585 }
31586 }
31587
31588 13492 int32_t HeroClass::getDivineProtectionShieldClk()
31589 {
31590 13492 return DivineProtectionShieldClk;
31591 }
31592
31593 21 int32_t HeroClass::getHoverClk()
31594 {
31595 21 return hoverclk;
31596 }
31597
31598 7642228 int32_t HeroClass::getHoldClk()
31599 {
31600 7642228 return holdclk;
31601 }
31602
31603 4273748 int32_t HeroClass::getLastLensID(){
31604 4273748 return last_lens_id;
31605 }
31606
31607 209 void HeroClass::setLastLensID(int32_t p_item){
31608 209 last_lens_id = p_item;
31609 209 }
31610
31611 53438404 bool HeroClass::getOnSideviewLadder()
31612 {
31613 53438404 return on_sideview_ladder;
31614 }
31615
31616 95 void HeroClass::setOnSideviewLadder(bool val)
31617 {
31618
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 9 times.
95 if(val)
31619 {
31620 9 fall = fakefall = hoverclk = jumping = 0;
31621 9 hoverflags = 0;
31622 9 inair = false;
31623 9 }
31624 95 on_sideview_ladder = val;
31625 95 }
31626
31627 1914071 bool HeroClass::canSideviewLadder(bool down)
31628 {
31629
2/2
✓ Branch 0 taken 1876860 times.
✓ Branch 1 taken 37211 times.
1914071 if(!isSideViewHero()) return false;
31630
2/2
✓ Branch 0 taken 24005 times.
✓ Branch 1 taken 13206 times.
37211 if(jumping < 0) return false;
31631
3/4
✓ Branch 0 taken 10405 times.
✓ Branch 1 taken 13600 times.
✓ Branch 2 taken 10405 times.
✗ Branch 3 not taken.
24005 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
31632 {
31633 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
31634 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
31635 }
31636 //Are you presently able to climb a sideview ladder?
31637 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
31638 //y+0 checks your top-half for large hitbox; y+8 for small
31639 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
31640 //y+16 check is for going down onto a ladder you are standing on.
31641
2/2
✓ Branch 0 taken 23588 times.
✓ Branch 1 taken 417 times.
47432 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
31642
4/4
✓ Branch 0 taken 23427 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 23382 times.
✓ Branch 3 taken 45 times.
23588 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
31643
5/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 23360 times.
✓ Branch 2 taken 12955 times.
✓ Branch 3 taken 10405 times.
✓ Branch 4 taken 10405 times.
✗ Branch 5 not taken.
33787 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
31644 1914071 }
31645
31646 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
31647 {
31648 if(!isSideViewHero()) return false;
31649 if(jumping < 0) return false;
31650 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
31651 {
31652 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
31653 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
31654 }
31655 //Are you presently able to climb a sideview ladder?
31656 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
31657 //y+0 checks your top-half for large hitbox; y+8 for small
31658 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
31659 //y+16 check is for going down onto a ladder you are standing on.
31660 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
31661 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
31662 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
31663 }
31664
31665 3964378 void HeroClass::execute(HeroClass::WalkflagInfo info)
31666 {
31667 3964378 int32_t flags = info.getFlags();
31668
31669
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 3963730 times.
3964378 if(flags & WalkflagInfo::CLEARILSWIM)
31670 648 ilswim =false;
31671
2/2
✓ Branch 0 taken 3962934 times.
✓ Branch 1 taken 796 times.
3963730 else if(flags & WalkflagInfo::SETILSWIM)
31672 796 ilswim = true;
31673
31674
1/2
✓ Branch 0 taken 3964378 times.
✗ Branch 1 not taken.
3964378 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
31675 {
31676 charging = 0;
31677 attackclk = 0;
31678 }
31679
31680
1/2
✓ Branch 0 taken 3964378 times.
✗ Branch 1 not taken.
3964378 if(flags & WalkflagInfo::SETDIR)
31681 {
31682 dir = info.getDir();
31683 }
31684
31685
2/2
✓ Branch 0 taken 3963801 times.
✓ Branch 1 taken 577 times.
3964378 if(flags & WalkflagInfo::SETHOPCLK)
31686 {
31687 577 hopclk = info.getHopClk();
31688 577 }
31689
31690
2/2
✓ Branch 0 taken 3963880 times.
✓ Branch 1 taken 498 times.
3964378 if(flags & WalkflagInfo::SETHOPDIR)
31691 {
31692 498 hopdir = info.getHopDir();
31693 498 }
31694
31695 3964378 }
31696
31697 8567906 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
31698 {
31699 8567906 HeroClass::WalkflagInfo ret;
31700 8567906 ret.newhopclk = newhopclk;
31701 8567906 ret.newdir = newdir;
31702
2/2
✓ Branch 0 taken 7099112 times.
✓ Branch 1 taken 1468794 times.
8567906 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
31703
31704 8567906 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
31705 8567906 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
31706 8567906 ret.flags = flags1 | flags2;
31707 8567906 return ret;
31708 }
31709
31710 48864 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
31711 {
31712 48864 HeroClass::WalkflagInfo ret;
31713 48864 ret.newhopclk = newhopclk;
31714 48864 ret.newdir = newdir;
31715
1/2
✓ Branch 0 taken 48864 times.
✗ Branch 1 not taken.
48864 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
31716
31717 48864 ret.flags = flags & other.flags;
31718 48864 return ret;
31719 }
31720
31721 48864 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
31722 {
31723 48864 HeroClass::WalkflagInfo ret;
31724 48864 ret.newhopclk = newhopclk;
31725 48864 ret.newdir = newdir;
31726 48864 ret.newhopdir = newhopdir;
31727
31728 48864 ret.flags = flags ^ UNWALKABLE;
31729 48864 return ret;
31730 }
31731
31732 void HeroClass::explode(int32_t type)
31733 {
31734 static int32_t tempx, tempy;
31735 static byte herotilebuf[256];
31736 int32_t ltile=0;
31737 int32_t lflip=0;
31738 bool shieldModify=true;
31739 unpack_tile(newtilebuf, tile, flip, true);
31740 memcpy(herotilebuf, unpackbuf, 256);
31741 tempx=Hero.getX();
31742 tempy=Hero.getY();
31743 for(int32_t i=0; i<16; ++i)
31744 {
31745 for(int32_t j=0; j<16; ++j)
31746 {
31747 if(herotilebuf[i*16+j])
31748 {
31749 if(type==0) // Twilight
31750 {
31751 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
31752 int32_t k=particles.Count()-1;
31753 particle *p = (particles.at(k));
31754 p->step=3;
31755 }
31756 else if(type ==1) // Sands of Hours
31757 {
31758 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
31759 int32_t k=particles.Count()-1;
31760 particle *p = (particles.at(k));
31761 p->step=4;
31762
31763 if(zc_oldrand()%10 < 2)
31764 {
31765 p->color=1;
31766 p->cset=0;
31767 }
31768 }
31769 else
31770 {
31771 particles.add(new pDivineEscapeDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
31772
31773 int32_t k=particles.Count()-1;
31774 particle *p = (particles.at(k));
31775 p->angular=true;
31776 p->angle=zc_oldrand();
31777 p->step=(((double)j)/8);
31778 p->yofs=Hero.getYOfs();
31779 }
31780 }
31781 }
31782 }
31783 }
31784
31785 984 void HeroClass::SetSwim()
31786 {
31787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 984 times.
984 if (CanSideSwim())
31788 {
31789 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
31790 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
31791 if (get_bit(quest_rules,qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
31792 }
31793 984 else {action=swimming; FFCore.setHeroAction(swimming);}
31794 984 }
31795
31796 60436 void HeroClass::SetAttack()
31797 {
31798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60436 times.
60436 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
31799 60436 else {action=attacking; FFCore.setHeroAction(attacking);}
31800 60436 }
31801
31802 53153006 bool HeroClass::IsSideSwim()
31803 {
31804
6/12
✓ Branch 0 taken 53153006 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53153006 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53153006 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 53153006 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 53153006 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 53153006 times.
53153006 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
31805 }
31806
31807 1532064 bool HeroClass::CanSideSwim()
31808 {
31809
1/2
✓ Branch 0 taken 1532064 times.
✗ Branch 1 not taken.
1532064 return (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM));
31810 }
31811
31812 5076266 int32_t HeroClass::getTileModifier()
31813 {
31814 5076266 return item_tile_mod() + bunny_tile_mod();
31815 }
31816 void HeroClass::setImmortal(int32_t nimmortal)
31817 {
31818 immortal = nimmortal;
31819 }
31820 void HeroClass::kill(bool bypassFairy)
31821 {
31822 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
31823 }
31824 12877701 bool HeroClass::sideview_mode() const
31825 {
31826
3/4
✓ Branch 0 taken 548487 times.
✓ Branch 1 taken 12329214 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 548487 times.
12877701 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
31827 }
31828 9441 bool HeroClass::is_unpushable() const
31829 {
31830 9441 return toogam;
31831 }
31832